diff --git a/plugins/pipo/.classpath b/plugins/pipo/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/plugins/pipo/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/pipo/.project b/plugins/pipo/.project new file mode 100644 index 0000000000..3c9fc47d88 --- /dev/null +++ b/plugins/pipo/.project @@ -0,0 +1,28 @@ + + + pipo + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/plugins/pipo/.settings/org.eclipse.jdt.core.prefs b/plugins/pipo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..ceb61221f1 --- /dev/null +++ b/plugins/pipo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Fri Mar 12 08:48:46 CET 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/plugins/pipo/.settings/org.eclipse.pde.core.prefs b/plugins/pipo/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 0000000000..173c0ad34c --- /dev/null +++ b/plugins/pipo/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,4 @@ +#Fri Mar 12 15:16:08 CET 2010 +eclipse.preferences.version=1 +pluginProject.extensions=true +resolve.requirebundle=false diff --git a/plugins/pipo/META-INF/MANIFEST.MF b/plugins/pipo/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..7614ebbee9 --- /dev/null +++ b/plugins/pipo/META-INF/MANIFEST.MF @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: PiPo +Bundle-SymbolicName: org.adempiere.pipo;singleton:=true +Bundle-Version: 0.0.0.1 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Import-Package: org.adempiere.base, + org.adempiere.pipo, + org.compiere, + org.compiere.util diff --git a/plugins/pipo/build.properties b/plugins/pipo/build.properties new file mode 100644 index 0000000000..e9863e281e --- /dev/null +++ b/plugins/pipo/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/plugins/pipo/plugin.xml b/plugins/pipo/plugin.xml new file mode 100644 index 0000000000..61312c4cbb --- /dev/null +++ b/plugins/pipo/plugin.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/plugins/pipo/src/org/adempiere/pipo/PipoDictionaryService.java b/plugins/pipo/src/org/adempiere/pipo/PipoDictionaryService.java new file mode 100644 index 0000000000..300fc164a6 --- /dev/null +++ b/plugins/pipo/src/org/adempiere/pipo/PipoDictionaryService.java @@ -0,0 +1,74 @@ +package org.adempiere.pipo; + +import java.io.File; +import java.io.InputStream; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.adempiere.base.IDictionaryService; +import org.compiere.Adempiere; +import org.compiere.util.DB; +import org.compiere.util.Trx; + +public class PipoDictionaryService implements IDictionaryService { + + Logger logger = Logger.getLogger(PipoDictionaryService.class.getName()); + + @Override + public void merge(InputStream model) throws Exception { + if (model == null) { + logger.info("No PackIn Model found"); + return; + } + try { + String trxName = Trx.createTrxName(); + logger.info("starting " + trxName); + PackIn.m_UpdateMode = "true"; + if (DB.isOracle()) + PackIn.m_Database = "Oracle"; + else if (DB.isPostgreSQL()) + PackIn.m_Database = "PostgreSQL"; + PackIn.m_Package_Dir = getPackageDir(); + + System.setProperty("javax.xml.parsers.SAXParserFactory", + "org.apache.xerces.jaxp.SAXParserFactoryImpl"); + PackInHandler handler = new PackInHandler(); + handler.set_TrxName(trxName); + handler.setCtx(null); + PackIn packIn = new PackIn(); + handler.setProcess(packIn); + SAXParserFactory factory = SAXParserFactory.newInstance(); + SAXParser parser = factory.newSAXParser(); + logger.info("Start Parser"); + parser.parse(model, handler); + logger.info("End Parser"); + Trx.get(trxName, false).commit(); + logger.info("commit " + trxName); + } catch (Exception e) { + logger.log(Level.SEVERE, "importXML:", e); + throw e; + } + + } + + private String getPackageDir() { + + // Create Target directory if required + String packageDirectory = Adempiere.getAdempiereHome(); + String result = packageDirectory + File.separator + + "packages"; + File docDir = new File( result+File.separator+"doc"); + + if (!docDir.exists()) { + boolean success = docDir.mkdirs(); + if (!success) { + logger.info("Target directory creation failed"); + } + } + return result; + } + +}