[Product Services] Merged Services branch
authorAaron Calero <aaron.calero@openbravo.com>
Tue, 24 Nov 2015 17:19:18 +0100
changeset 28647 a62bdb1a82a3
parent 28646 7d8b06f475a6 (current diff)
parent 28338 53de6573ff6e (diff)
child 28648 64b00fc3c5f1
[Product Services] Merged Services branch
src-db/database/sourcedata/AD_FIELD.xml
src/org/openbravo/service/importprocess/ImportEntryProcessor.java
--- a/src-db/database/sourcedata/AD_FIELD.xml	Tue Nov 24 13:50:04 2015 +0100
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Tue Nov 24 17:19:18 2015 +0100
@@ -197821,7 +197821,7 @@
 <!--317E7BE2AEB1474F9F37D3C115B72EB6-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--317E7BE2AEB1474F9F37D3C115B72EB6-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--317E7BE2AEB1474F9F37D3C115B72EB6-->  <DISPLAYLENGTH><![CDATA[32]]></DISPLAYLENGTH>
-<!--317E7BE2AEB1474F9F37D3C115B72EB6-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--317E7BE2AEB1474F9F37D3C115B72EB6-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
 <!--317E7BE2AEB1474F9F37D3C115B72EB6-->  <SEQNO><![CDATA[50]]></SEQNO>
 <!--317E7BE2AEB1474F9F37D3C115B72EB6-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--317E7BE2AEB1474F9F37D3C115B72EB6-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/service/importprocess/ImportEntryPostProcessor.java	Tue Nov 24 17:19:18 2015 +0100
@@ -0,0 +1,33 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.service.importprocess;
+
+import org.openbravo.service.importprocess.ImportEntryProcessor.ImportEntryProcessRunnable;
+
+/**
+ * Abstract/default class used to inject logic to an Import Entry when its process is finished and
+ * the commit is done.
+ * 
+ * Is called from the {@link ImportEntryProcessRunnable#doRunCycle()} method.
+ * 
+ */
+public abstract class ImportEntryPostProcessor {
+
+  public abstract void afterProcessing(ImportEntry importEntry);
+}
--- a/src/org/openbravo/service/importprocess/ImportEntryProcessor.java	Tue Nov 24 13:50:04 2015 +0100
+++ b/src/org/openbravo/service/importprocess/ImportEntryProcessor.java	Tue Nov 24 17:19:18 2015 +0100
@@ -29,6 +29,8 @@
 import java.util.concurrent.ExecutorService;
 
 import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Instance;
 import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
@@ -40,6 +42,7 @@
 import org.openbravo.dal.core.TriggerHandler;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.service.importprocess.ImportEntryManager.ImportEntryProcessorSelector;
 
 /**
  * The {@link ImportEntryProcessor} is responsible for importing/processing {@link ImportEntry}
@@ -270,6 +273,10 @@
     // when the garbagecollector runs
     private Map<String, OBContext> cachedOBContexts = new HashMap<String, OBContext>();
 
+    @Inject
+    @Any
+    private Instance<ImportEntryPostProcessor> importEntryPostProcessors;
+
     public ImportEntryProcessRunnable() {
       logger = Logger.getLogger(this.getClass());
     }
@@ -356,6 +363,12 @@
 
           processEntry(localImportEntry);
 
+          // Execute post process hooks.
+          for (ImportEntryPostProcessor importEntryPostProcessor : importEntryPostProcessors
+              .select(new ImportEntryProcessorSelector(typeOfData))) {
+            importEntryPostProcessor.afterProcessing(localImportEntry);
+          }
+
           if (logger.isDebugEnabled()) {
             logger.debug("Finished Processing entry " + localImportEntry.getIdentifier() + " "
                 + typeOfData);