1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
class UnThread extends Thread{
private static final String pathwintif = getProperty("sogerma.tiffiles.pathwin","\\\\Aldebaran\\pdmlinkshare");
private String pathdelimwin = "\\";
private String pathdelim = java.io.File.separator;
private static String getProperty( String propName, String valeurDefaut ) {
String valeur = valeurDefaut;
try
{
valeur = SogermaHelper.manager.getProperty( propName, valeurDefaut );
}
catch ( WTException e )
{
System.out.println("Impossible de récupérer la propriété [" + propName + "]");
e.printStackTrace();
}
return valeur;
}
//Cette méthode lance le chargement du fichier -LOAD.XML pour créer le document
private boolean loadXML(WTPart part, String path, String fileName){
Hashtable nv = new Hashtable();
String product = sgUtils.getAttrib(part,"ContainerName");
if(path==null){
path = System.getProperty("user.dir");
}
try {
String sgOrganizationName=null;
sgOrganizationName = WTProperties.getLocalProperties().getProperty("sogerma.organization.name");
nv.put("CONT_PATH", "/wt.inf.container.OrgContainer=" + sgOrganizationName + "/wt.pdmlink.PDMLinkProduct=" + product);
LoadFromFile.doFileImport(path + pathdelim + fileName , null, null, null, null, null, nv);
}
catch (WTException e) {
e.printStackTrace();
return false;
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
public void run(EPMDocument epmdoc, WTPart part, String fileName){
String Number = epmdoc.getNumber();
String Version = epmdoc.getVersionDisplayIdentifier().toString();
String DRAWING = Number + Version;
//creation de l'instance du Thread
UnThread Thread = new UnThread();
//activation du Thread
Thread.start();
//tant que le Thread est en vie
while(Thread.isAlive()){
//faire un traitement
//vérifier si de nouveaux fichiers TIFF générés sont apparus dans le répertoire de génération des fichiers tif
String file_tif = pathwintif + pathdelimwin + DRAWING + ".tif";
File f = new File("file_tif");
String[] listefichiers = f.list();
for (int i = 0; listefichiers != null && i < listefichiers.length; i++) {
if(listefichiers[i].endsWith(".tif")==true){
System.out.println(listefichiers[i]);
//récupéré les fichiers TIFF et les integrer dans le PDM
}
}
//load du fichier tif à partir du fichier xml
String path = System.getProperty("user.dir");
boolean load = loadXLM(part, path, fileName);
//vérifier si il existe le fichier XML pour loader le fichier tif dans PDMLink
for (int i = 0; listefichiers!= null && i < listefichiers.length; i++) {
if(listefichiers[i].endsWith(".xml")==true){
//rechercher dans le fichier XML la valeur de <xmlpartNumber>
//rechercher le WTPart pour cet article
String number = part.getNumber();
String partNumber = number ;
WTPart article = sgUtils.getPart(partNumber);
}
}
// test ok
try{
//faire une pause de 100 pour simuler un traitement
Thread.sleep(100);
}
catch(InterruptedException ex){}
}
}
} |
Partager