|
From: <das...@us...> - 2008-10-29 19:49:46
|
Revision: 1179
http://vlab.svn.sourceforge.net/vlab/?rev=1179&view=rev
Author: dasil014
Date: 2008-10-29 19:49:42 +0000 (Wed, 29 Oct 2008)
Log Message:
-----------
I moved all post-processing methods to a specific class. This class is just called from other class when it needs a pos-processing.
Added Paths:
-----------
trunk/vlab/services/project-executor/src/main/java/org/vlab/services/PostProcessing.java
Added: trunk/vlab/services/project-executor/src/main/java/org/vlab/services/PostProcessing.java
===================================================================
--- trunk/vlab/services/project-executor/src/main/java/org/vlab/services/PostProcessing.java (rev 0)
+++ trunk/vlab/services/project-executor/src/main/java/org/vlab/services/PostProcessing.java 2008-10-29 19:49:42 UTC (rev 1179)
@@ -0,0 +1,552 @@
+package org.vlab.services;
+
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Vector;
+import java.io.*;
+import java.net.URL;
+import org.exolab.castor.xml.Marshaller;
+import org.exolab.castor.xml.Unmarshaller;
+
+import org.apache.axis.encoding.Base64;
+
+public class PostProcessing {
+
+ private boolean filter;
+
+ private boolean duplicateinput;
+
+ private boolean replacedata;
+
+ private boolean assemblyfitting;
+
+ private boolean runposprocessing;
+
+
+
+public static void getOutPutTask(Receipt phaseReceipt, String ProjectType, Boolean phaseOption){
+
+ System.out.println("\n Here I am on getOutPutTask \n");
+
+ Executor TaskExec = null;
+ byte[] DataToFile = null;
+ File OutPutFile = null;
+ String StringOutPutPwscf = null;
+ String fullUrl = null;
+ String packageName = null;
+ StringWriter classXmlFile = null;
+ OutputStream srcDest = null;
+ int buffsizeWS = 0;
+
+ Bdata bdataContent = null;
+ List listTask = null;
+ List listBdata = null;
+
+ try{
+ //if (projectType.equals("1")) listTask = phaseReceipt1.getAttachamments();
+
+ //if (projectType.equals("2") && phaseOption.booleanValue()==true) listTask = phaseReceipt2.getAttachamments();
+
+ //if (projectType.equals("2") && phaseOption.booleanValue()==false) listTask = phaseReceipt3.getAttachamments();
+
+ listTask = phaseReceipt.getAttachamments();
+
+ } catch(Exception ae){
+ System.err.println("[ProjectExecutor::getOutPutTask()] Error setting the Phase options to get output: "+ae.getMessage());
+ ae.printStackTrace();
+ //System.exit(-1);
+ }
+
+ //listTask = phaseReceipt.getAttachamments();
+
+ try{
+
+ Receipt newtaskReceipt = new Receipt();
+
+ for(int j=0;j < listTask.size(); j++){
+ newtaskReceipt = (Receipt) (listTask.get(j));
+ listBdata = newtaskReceipt.getContent();
+
+ for(int k=0; k < listBdata.size(); k++){
+
+ bdataContent = (Bdata) (listBdata.get(k));
+
+ if (bdataContent.getKeyword().equals("IPADDRESS")){
+ fullUrl = bdataContent.getSvalue();
+ }
+
+ if (bdataContent.getKeyword().equals("PACKAGENAME")){
+ packageName = bdataContent.getSvalue();
+ }
+ }
+ TaskExec = new ExecutorServiceLocator().getTaskExecutor(new URL(fullUrl));
+ System.out.println("I got step1 instanciando Task Executor");
+ ((TaskExecutorSoapBindingStub)TaskExec).setMaintainSession(true);
+ System.out.println("I got step2 instanciando Task Executor");
+
+ classXmlFile = new StringWriter();
+
+ try{
+ Marshaller.marshal(newtaskReceipt,classXmlFile);
+ } catch (Exception ae){
+ System.err.println("[ProjectExecutor::getOutPutTask()] On Castor XMl conversor => Error : " + ae.getMessage());
+ ae.printStackTrace();
+ //System.exit(-1);
+ }
+
+ //System.out.println("My class right now is: "+classXmlFile.toString());
+
+ TaskExec.setStringTaskReceipt(classXmlFile.toString());
+ TaskExec.setProjectType(ProjectType);
+ TaskExec.prepare_path_to_get_output();
+
+ /* This method just prepared the Output to be get by getStringOutPutPwscf() */
+ System.out.println("Here I started to take the output file to: " + ProjectExecutor.ENV_PACKAGE_DIR + ProjectExecutor.dirEPName + packageName);
+ TaskExec.setFileIndex(0);
+ TaskExec.readFile();
+
+ OutPutFile = new File(ProjectExecutor.ENV_PACKAGE_DIR + ProjectExecutor.dirEPName + packageName + "/Pwscf_Output");
+ srcDest = new FileOutputStream(OutPutFile);
+
+ while((buffsizeWS = TaskExec.buffsize()) >= 0){
+ TaskExec.getOutPut();
+ StringOutPutPwscf = TaskExec.getStringOutPutPwscf();
+ DataToFile = Base64.decode(StringOutPutPwscf);
+ srcDest.write(DataToFile, 0, buffsizeWS);
+ }
+ System.out.println("Here I got " + ProjectExecutor.ENV_PACKAGE_DIR + ProjectExecutor.dirEPName + packageName);
+ //OutPutFile = new File(this.ENV_PACKAGE_DIR + this.dirEPName);
+ //OutPutFile.mkdir();
+ //System.out.println("File name: " + OutPutFile.getName());
+ //System.out.println("File Size: " + DataToFile.length);
+ srcDest.close();
+
+
+ /* This method just prepared the Output to be get by getStringOutPutPwscf()
+ System.out.println("This method just prepared the Output to be get by getStringOutPutPwscf()");
+ TaskExec.getOutPut();
+
+ System.out.println(" This next method getStringOutPutPwscf() get the OutPut on Base64 format ");
+
+ StringOutPutPwscf = TaskExec.getStringOutPutPwscf();
+ DataToFile = Base64.decode(StringOutPutPwscf);
+
+ //OutPutFile = new File(this.ENV_PACKAGE_DIR + this.dirEPName);
+ //OutPutFile.mkdir();
+ OutPutFile = new File(this.ENV_PACKAGE_DIR + this.dirEPName + packageName + "/Pwscf_Output");
+ System.out.println("File name: " + OutPutFile.getName());
+ System.out.println("File Size: " + DataToFile.length);
+ OutputStream srcDest = new FileOutputStream(OutPutFile);
+ srcDest.write(DataToFile, 0, DataToFile.length);
+ srcDest.close();
+ */
+
+ }
+ } catch (Exception ae){
+ System.err.println("[ProjectExecutor::getOutPutTask()] => Error creating the OutPut File: " + ae.getMessage());
+ ae.printStackTrace();
+ //System.exit(-1);
+ }
+
+ srcDest = null;
+ }
+
+ public static void getOutPutTaskCij(Receipt phaseReceipt, String ProjectType, Boolean phaseOption){
+
+ System.out.println("\n Here I am on getOutPutTaskCij \n");
+
+ Executor TaskExec = null;
+ byte[] DataToFile = null;
+ File OutPutFile = null;
+ String StringOutPutPwscf = null;
+ String fullUrl = null;
+ String packageName = null;
+ StringWriter classXmlFile = null;
+ Bdata bdataContent = null;
+ OutputStream srcDest = null;
+ int buffsizeWS = 0;
+ List listBdata = null;
+ String[] ListOfEEPackages = null;
+ String ActuallyCCPackage = null;
+ String ActuallyEEPackage = null;
+
+ String AbsolutePathOutput = null;
+ int verify = 0;
+ List listTask = null;
+ String[] ListOfPackages = null;
+
+
+ try{
+ listTask = phaseReceipt.getAttachamments();
+ ListOfPackages = DispatcherSetting.ListPackages(ProjectType, phaseOption);
+ } catch (Exception ae){
+ System.err.println("[ProjectExecutor::getOutPutTaskCij()] Error getting the list of packages: "+ae.getMessage());
+ ae.printStackTrace();
+ //System.exit(-1);
+ }
+
+ try{
+ Receipt newtaskReceipt = new Receipt();
+ for(int j=0;j < listTask.size(); j++){
+ System.out.println("The Task Size is: "+listTask.size());
+ newtaskReceipt = (Receipt) (listTask.get(j));
+ listBdata = newtaskReceipt.getContent();
+
+ for(int k=0; k < listBdata.size(); k++){
+
+ bdataContent = (Bdata) (listBdata.get(k));
+
+ if (bdataContent.getKeyword().equals("IPADDRESS")){
+ fullUrl = bdataContent.getSvalue();
+ verify++;
+ }
+
+ if (bdataContent.getKeyword().equals("PACKAGENAME")){
+ packageName = bdataContent.getSvalue();
+
+
+ for(int i=0;i<ListOfPackages.length;i++){
+ ActuallyCCPackage = ListOfPackages[i];
+ ListOfEEPackages = DispatcherSetting.ListEEPackages(ActuallyCCPackage,false);
+ for(int p=0; p<ListOfEEPackages.length; p++){
+ ActuallyEEPackage = ListOfEEPackages[p];
+
+ System.out.println("The EEPackage name is:"+ActuallyEEPackage);
+ System.out.println("The Package from receipt is: "+packageName);
+ if (packageName.equals(ActuallyEEPackage)){
+ verify++;
+ System.out.println("\n\nYES THE PACKAGES ARE EQUALS\n\n");
+ AbsolutePathOutput = ProjectExecutor.ENV_PACKAGE_DIR + ProjectExecutor.dirEPName + "/"+ ActuallyCCPackage.substring(0,ActuallyCCPackage.length()-4) + "/" + ActuallyEEPackage;
+ }
+ }
+ }
+ }
+ }
+
+ if(verify!=0 && verify%2==0){
+ System.out.println("Here I start reading the output");
+ TaskExec = new ExecutorServiceLocator().getTaskExecutor(new URL(fullUrl));
+ System.out.println("I got step1 instanciando Task Executor");
+ ((TaskExecutorSoapBindingStub)TaskExec).setMaintainSession(true);
+ System.out.println("I got step2 instanciando Task Executor");
+
+ classXmlFile = new StringWriter();
+
+ try{
+ Marshaller.marshal(newtaskReceipt,classXmlFile);
+ } catch (Exception ae){
+ System.err.println("[ProjectExecutor::getOutPutTaskCij()] On Castor XMl conversor => Error : " + ae.getMessage());
+ ae.printStackTrace();
+ //System.exit(-1);
+ }
+
+ //System.out.println("My class right now is: "+classXmlFile.toString());
+
+ TaskExec.setStringTaskReceipt(classXmlFile.toString());
+ TaskExec.setProjectType(ProjectType);
+ TaskExec.prepare_path_to_get_output();
+
+ /* This method just prepared the Output to be get by getStringOutPutPwscf() */
+ System.out.println("Here I started to take the output file to: " + AbsolutePathOutput);
+ TaskExec.setFileIndex(0);
+ TaskExec.readFile();
+
+ OutPutFile = new File(AbsolutePathOutput + "/Pwscf_Output");
+ srcDest = new FileOutputStream(OutPutFile);
+
+ while((buffsizeWS = TaskExec.buffsize()) >= 0){
+ if (buffsizeWS == -1){
+ System.out.println("[Failed to get the Output]");
+ break;
+ }
+ TaskExec.getOutPut();
+ StringOutPutPwscf = TaskExec.getStringOutPutPwscf();
+ DataToFile = Base64.decode(StringOutPutPwscf);
+ srcDest.write(DataToFile, 0, buffsizeWS);
+ }
+ System.out.println("Here I got "+AbsolutePathOutput);
+ //OutPutFile = new File(this.ENV_PACKAGE_DIR + this.dirEPName);
+ //OutPutFile.mkdir();
+ //System.out.println("File name: " + OutPutFile.getName());
+ //System.out.println("File Size: " + DataToFile.length);
+ srcDest.close();
+
+ }
+ verify=0;
+ }
+ } catch (Exception ae){
+ System.err.println("[ProjectExecutor::getOutPutTaskCij()] => Error creating the OutPut File: " + ae.getMessage());
+ ae.printStackTrace();
+ //System.exit(-1);
+ }
+ srcDest = null;
+ }
+
+ public static void getOutPutTaskHighTempThermo(Receipt phaseReceipt, String ProjectType, Boolean phaseOption){
+
+ System.out.println("\n Here I am on getOutPutTaskHighTempThermo \n");
+
+ Executor TaskExec = null;
+ byte[] DataToFile = null;
+ File OutPutFile = null;
+ String StringOutPutFile = null;
+ String fullUrl = null;
+ String packageName = null;
+ StringWriter classXmlFile = null;
+ Bdata bdataContent = null;
+ OutputStream srcDest = null;
+ String[] ListOfPHPackages = null;
+ String ActuallyCCPackage = null;
+ String ActuallyPHPackage = null;
+
+ String AbsolutePathOutput = null;
+ List listTask = null;
+ int verify = 0;
+ List listBdata = null;
+ String[] ListOfPackages = null;
+ int buffsizeWS = 0;
+ String StringOutPutPwscf = null;
+
+ try{
+ listTask = phaseReceipt.getAttachamments();
+
+ ListOfPackages = DispatcherSetting.ListPackages(ProjectType, phaseOption);
+ } catch(Exception ae){
+ System.err.println("[ProjectExecutor::getOutPutTaskHighTempThermo()] Error getting the HighPT packages: "+ae.getMessage());
+ ae.printStackTrace();
+ //System.exit(-1);
+ }
+
+ try{
+ Receipt newtaskReceipt = new Receipt();
+ for(int j=0;j < listTask.size(); j++){
+ System.out.println("The Task Size is: "+listTask.size());
+ newtaskReceipt = (Receipt) (listTask.get(j));
+ listBdata = newtaskReceipt.getContent();
+
+ for(int k=0; k < listBdata.size(); k++){
+
+ bdataContent = (Bdata) (listBdata.get(k));
+
+ if (bdataContent.getKeyword().equals("IPADDRESS")){
+ fullUrl = bdataContent.getSvalue();
+ verify++;
+ }
+
+ if (bdataContent.getKeyword().equals("PACKAGENAME")){
+ packageName = bdataContent.getSvalue();
+
+
+ for(int i=0;i<ListOfPackages.length;i++){
+ ActuallyCCPackage = ListOfPackages[i];
+ ListOfPHPackages = DispatcherSetting.ListPHPackages(ActuallyCCPackage, false); //ListEEPackages(ActuallyCCPackage,false);
+ for(int p=0; p<ListOfPHPackages.length; p++){
+ ActuallyPHPackage = ListOfPHPackages[p];
+
+ System.out.println("The EEPackage name is:"+ActuallyPHPackage);
+ System.out.println("The Package from receipt is: "+packageName);
+ if (packageName.equals(ActuallyPHPackage)){
+ verify++;
+ System.out.println("\n\nYES THE PACKAGES ARE EQUALS\n\n");
+ AbsolutePathOutput = ProjectExecutor.ENV_PACKAGE_DIR + ProjectExecutor.dirEPName + "/"+ ActuallyCCPackage.substring(0,ActuallyCCPackage.length()-4) + "/" + ActuallyPHPackage;
+ }
+ }
+ }
+ }
+ }
+
+ if(verify!=0 && verify%2==0){
+ System.out.println("Here I start reading the output");
+ TaskExec = new ExecutorServiceLocator().getTaskExecutor(new URL(fullUrl));
+ System.out.println("I got step1 instanciando Task Executor");
+ ((TaskExecutorSoapBindingStub)TaskExec).setMaintainSession(true);
+ System.out.println("I got step2 instanciando Task Executor");
+
+ classXmlFile = new StringWriter();
+
+ try{
+ Marshaller.marshal(newtaskReceipt,classXmlFile);
+ } catch (Exception ae){
+ System.err.println("[ProjectExecutor::getOutPutTaskHighTempThermo()] On Castor XMl conversor => Error : " + ae.getMessage());
+ ae.printStackTrace();
+ //System.exit(-1);
+ }
+
+
+ TaskExec.setStringTaskReceipt(classXmlFile.toString());
+ TaskExec.setProjectType(ProjectType);
+ TaskExec.prepare_path_to_get_output();
+
+ /* This method just prepared the Output to be get by getStringOutPutPwscf() */
+ System.out.println("Here I started to take the output file to: " + AbsolutePathOutput + "Pwscf_Output2");
+ TaskExec.setFileIndex(1);//Index_1 => Pwscf_Output2; Index_2 => Pwscf_Output3; Index_3 => Phonon_Output; Index_4 => matdyn
+ TaskExec.readFile();
+
+ OutPutFile = new File(AbsolutePathOutput + "/Pwscf_Output2");
+ srcDest = new FileOutputStream(OutPutFile);
+
+ while((buffsizeWS = TaskExec.buffsize()) >= 0){
+ if (buffsizeWS == -1){
+ System.out.println("[Failed to get the Output]");
+ break;
+ }
+ TaskExec.getOutPut();
+ StringOutPutPwscf = TaskExec.getStringOutPutPwscf();
+ DataToFile = Base64.decode(StringOutPutPwscf);
+ srcDest.write(DataToFile, 0, buffsizeWS);
+ }
+ System.out.println("Here I got "+AbsolutePathOutput);
+ srcDest.close();
+
+ /* This method just prepared the Output to be get by getStringOutPutPwscf() */
+ System.out.println("Here I started to take the output file to: " + AbsolutePathOutput + "Pwscf_Output3");
+ TaskExec.setFileIndex(2);//Index_1 => Pwscf_Output2; Index_2 => Pwscf_Output3; Index_3 => Phonon_Output; Index_4 => matdyn
+ TaskExec.readFile();
+
+ OutPutFile = new File(AbsolutePathOutput + "/Pwscf_Output3");
+ srcDest = new FileOutputStream(OutPutFile);
+
+ while((buffsizeWS = TaskExec.buffsize()) >= 0){
+ if (buffsizeWS == -1){
+ System.out.println("[Failed to get the Output]");
+ break;
+ }
+ TaskExec.getOutPut();
+ StringOutPutPwscf = TaskExec.getStringOutPutPwscf();
+ DataToFile = Base64.decode(StringOutPutPwscf);
+ srcDest.write(DataToFile, 0, buffsizeWS);
+ }
+ System.out.println("Here I got "+AbsolutePathOutput);
+ srcDest.close();
+
+
+
+
+ /* This method just prepared the Output to be get by getStringOutPutPwscf() */
+ System.out.println("Here I started to take the output file to: " + AbsolutePathOutput + "Phonon_Output");
+ TaskExec.setFileIndex(3);//Index_1 => Pwscf_Output2; Index_2 => Pwscf_Output3; Index_3 => Phonon_Output; Index_4 => matdyn
+ TaskExec.readFile();
+
+ OutPutFile = new File(AbsolutePathOutput + "/Phonon_Output");
+ srcDest = new FileOutputStream(OutPutFile);
+
+ while((buffsizeWS = TaskExec.buffsize()) >= 0){
+ if (buffsizeWS == -1){
+ System.out.println("[Failed to get the Output]");
+ break;
+ }
+ TaskExec.getOutPut();
+ StringOutPutPwscf = TaskExec.getStringOutPutPwscf();
+ DataToFile = Base64.decode(StringOutPutPwscf);
+ srcDest.write(DataToFile, 0, buffsizeWS);
+ }
+ System.out.println("Here I got "+AbsolutePathOutput);
+ srcDest.close();
+
+
+ /* This method just prepared the Output to be get by getStringOutPutPwscf() */
+ System.out.println("Here I started to take the output file to: " + AbsolutePathOutput + "matdyn");
+ TaskExec.setFileIndex(4);//Index_1 => Pwscf_Output2; Index_2 => Pwscf_Output3; Index_3 => Phonon_Output; Index_4 => matdyn
+ TaskExec.readFile();
+
+ OutPutFile = new File(AbsolutePathOutput + "/matdyn");
+ srcDest = new FileOutputStream(OutPutFile);
+
+ while((buffsizeWS = TaskExec.buffsize()) >= 0){
+ if (buffsizeWS == -1){
+ System.out.println("[Failed to get the Output]");
+ break;
+ }
+ TaskExec.getOutPut();
+ StringOutPutPwscf = TaskExec.getStringOutPutPwscf();
+ DataToFile = Base64.decode(StringOutPutPwscf);
+ srcDest.write(DataToFile, 0, buffsizeWS);
+ }
+ System.out.println("Here I got "+AbsolutePathOutput);
+ srcDest.close();
+
+ /*
+ //System.out.println("My class right now is: "+classXmlFile.toString());
+ TaskExec.setProjectType(getProjectType());
+ TaskExec.setStringTaskReceipt(classXmlFile.toString());
+ TaskExec.setProjectType(projectType);
+
+ //This method just prepared the Output to be get by getStringOutPutPwscf()
+ System.out.println("This method just prepared the Output to be get by getOutPutTaskHighTempThermo()");
+ TaskExec.getOutPut();
+
+ System.out.println(" This next method getStringOutPutPwscf() get the OutPut on Base64 format ");
+
+ StringOutPutFile = TaskExec.getStringOutPutPwscf2();
+ DataToFile = Base64.decode(StringOutPutFile);
+
+ OutPutFile = new File(AbsolutePathOutput + "/Pwscf_Output2");
+ System.out.println("File name: " + OutPutFile.getName());
+ System.out.println("File Size: " + DataToFile.length);
+ srcDest = new FileOutputStream(OutPutFile);
+ srcDest.write(DataToFile, 0, DataToFile.length);
+ srcDest.close();
+ srcDest = null;
+
+ StringOutPutFile = TaskExec.getStringOutPutPwscf3();
+ DataToFile = Base64.decode(StringOutPutFile);
+
+ OutPutFile = new File(AbsolutePathOutput + "/Pwscf_Output3");
+ System.out.println("File name: " + OutPutFile.getName());
+ System.out.println("File Size: " + DataToFile.length);
+ srcDest = new FileOutputStream(OutPutFile);
+ srcDest.write(DataToFile, 0, DataToFile.length);
+ srcDest.close();
+ srcDest = null;
+
+ StringOutPutFile = TaskExec.getStringOutPutPhonon();
+ DataToFile = Base64.decode(StringOutPutFile);
+
+ OutPutFile = new File(AbsolutePathOutput + "/Pwscf_Phonon");
+ System.out.println("File name: " + OutPutFile.getName());
+ System.out.println("File Size: " + DataToFile.length);
+ srcDest = new FileOutputStream(OutPutFile);
+ srcDest.write(DataToFile, 0, DataToFile.length);
+ srcDest.close();
+ srcDest = null;
+
+ StringOutPutFile = TaskExec.getStringOutPutMatdyn();
+ DataToFile = Base64.decode(StringOutPutFile);
+
+ OutPutFile = new File(AbsolutePathOutput + "/matdyn");
+ System.out.println("File name: " + OutPutFile.getName());
+ System.out.println("File Size: " + DataToFile.length);
+ srcDest = new FileOutputStream(OutPutFile);
+ srcDest.write(DataToFile, 0, DataToFile.length);
+ srcDest.close();
+ srcDest = null;
+ */
+
+ }
+ verify=0;
+ }
+ } catch (Exception ae){
+ System.err.println("[ProjectExecutor::getOutPutTaskHighTempThermo()] => Error creating the OutPut File: " + ae.getMessage());
+ ae.printStackTrace();
+ //System.exit(-1);
+ }
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|