pipo (2pack) dictionary service implementation
This commit is contained in:
parent
35233b2294
commit
21d6e6a8a2
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>pipo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -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
|
|
@ -0,0 +1,4 @@
|
|||
#Fri Mar 12 15:16:08 CET 2010
|
||||
eclipse.preferences.version=1
|
||||
pluginProject.extensions=true
|
||||
resolve.requirebundle=false
|
|
@ -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
|
|
@ -0,0 +1,5 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="org.adempiere.base.IDictionaryService">
|
||||
<client
|
||||
class="org.adempiere.pipo.PipoDictionaryService">
|
||||
</client>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue