diff --git a/framework/service/src/org/ofbiz/service/ModelService.java b/framework/service/src/org/ofbiz/service/ModelService.java index 089f02b311..5bc3dc1a75 100644 --- a/framework/service/src/org/ofbiz/service/ModelService.java +++ b/framework/service/src/org/ofbiz/service/ModelService.java @@ -18,45 +18,58 @@ *******************************************************************************/ package org.ofbiz.service; -import java.util.*; -import java.lang.reflect.Method; -import java.lang.reflect.Field; import java.io.Serializable; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.AbstractMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TimeZone; +import java.util.TreeSet; -import javax.wsdl.*; +import javax.wsdl.Binding; +import javax.wsdl.BindingInput; +import javax.wsdl.BindingOperation; +import javax.wsdl.BindingOutput; +import javax.wsdl.Definition; +import javax.wsdl.Input; +import javax.wsdl.Message; +import javax.wsdl.Operation; +import javax.wsdl.Output; +import javax.wsdl.Port; +import javax.wsdl.PortType; +import javax.wsdl.Service; +import javax.wsdl.WSDLException; +import javax.wsdl.extensions.soap.SOAPAddress; import javax.wsdl.extensions.soap.SOAPBinding; import javax.wsdl.extensions.soap.SOAPBody; import javax.wsdl.extensions.soap.SOAPOperation; -import javax.wsdl.extensions.soap.SOAPAddress; import javax.wsdl.factory.WSDLFactory; import javax.xml.namespace.QName; import javolution.util.FastList; import javolution.util.FastMap; -import com.ibm.wsdl.extensions.soap.SOAPBindingImpl; -import com.ibm.wsdl.extensions.soap.SOAPBodyImpl; -import com.ibm.wsdl.extensions.soap.SOAPOperationImpl; -import com.ibm.wsdl.extensions.soap.SOAPAddressImpl; - import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.ObjectType; import org.ofbiz.base.util.UtilDateTime; +import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; -import org.ofbiz.base.util.UtilMisc; -import org.ofbiz.entity.model.ModelField; -import org.ofbiz.entity.model.ModelFieldType; -import org.ofbiz.entity.model.ModelFieldTypeReader; -import org.ofbiz.entity.model.ModelKeyMap; -import org.ofbiz.entity.model.ModelRelation; import org.ofbiz.service.group.GroupModel; import org.ofbiz.service.group.GroupServiceModel; import org.ofbiz.service.group.ServiceGroupReader; - import org.w3c.dom.Document; +import com.ibm.wsdl.extensions.soap.SOAPAddressImpl; +import com.ibm.wsdl.extensions.soap.SOAPBindingImpl; +import com.ibm.wsdl.extensions.soap.SOAPBodyImpl; +import com.ibm.wsdl.extensions.soap.SOAPOperationImpl; + /** * Generic Service Model Class */ diff --git a/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java b/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java index 699150c094..7a37090d2a 100644 --- a/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java +++ b/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java @@ -60,36 +60,42 @@ public class ArtifactInfoFactory { public Map allEntityInfos = FastMap.newInstance(); public Map allServiceInfos = FastMap.newInstance(); + public Map allServiceEcaInfos = FastMap.newInstance(); public Map allFormInfos = FastMap.newInstance(); public Map allScreenInfos = FastMap.newInstance(); // reverse-associative caches for walking backward in the diagram public Map> allServiceEcaInfosReferringToServiceName = FastMap.newInstance(); public Map> allServiceInfosReferringToServiceName = FastMap.newInstance(); - public Map> allServiceInfosReferringToEntityName = FastMap.newInstance(); - public Map> allFormInfosReferringToServiceName = FastMap.newInstance(); - public Map> allFormInfosReferringToEntityName = FastMap.newInstance(); - public Map> allScreenInfosReferringToServiceName = FastMap.newInstance(); - public Map> allScreenInfosReferringToEntityName = FastMap.newInstance(); + public Map> allFormInfosReferringToServiceName = FastMap.newInstance(); + public Map> allScreenInfosReferringToServiceName = FastMap.newInstance(); - public static ArtifactInfoFactory makeArtifactInfoFactory(String delegatorName) throws GenericEntityException { + public Map> allServiceInfosReferringToEntityName = FastMap.newInstance(); + public Map> allFormInfosReferringToEntityName = FastMap.newInstance(); + public Map> allScreenInfosReferringToEntityName = FastMap.newInstance(); + + public Map> allServiceInfosReferringToServiceEcaRule = FastMap.newInstance(); + + public static ArtifactInfoFactory makeArtifactInfoFactory(String delegatorName) throws GeneralException { if (UtilValidate.isEmpty(delegatorName)) { delegatorName = "default"; } - ArtifactInfoFactory aic = artifactInfoFactoryCache.get(delegatorName); - if (aic == null) { - aic = new ArtifactInfoFactory(delegatorName); + ArtifactInfoFactory aif = artifactInfoFactoryCache.get(delegatorName); + if (aif == null) { + aif = new ArtifactInfoFactory(delegatorName); } - return aic; + return aif; } - protected ArtifactInfoFactory(String delegatorName) throws GenericEntityException { + protected ArtifactInfoFactory(String delegatorName) throws GeneralException { this.delegatorName = delegatorName; this.entityModelReader = ModelReader.getModelReader(delegatorName); this.dispatchContext = new DispatchContext("ArtifactInfoDispCtx", null, this.getClass().getClassLoader(), null); this.entityEcaCache = EntityEcaUtil.getEntityEcaCache(EntityEcaUtil.getEntityEcaReaderName(delegatorName)); this.serviceEcaCache = ServiceEcaUtil.ecaCache; + + this.prepareAll(); } public void prepareAll() throws GeneralException { @@ -103,7 +109,7 @@ public class ArtifactInfoFactory { this.getServiceArtifactInfo(serviceName); } - // TODO: how to get all Service ECAs to prepare? + // how to get all Service ECAs to prepare? don't worry about it, will be populated from service load, ie all ECAs for each service // TODO: how to get all forms to prepare? @@ -152,6 +158,15 @@ public class ArtifactInfoFactory { return curInfo; } + public ServiceEcaArtifactInfo getServiceEcaArtifactInfo(ServiceEcaRule ecaRule) throws GeneralException { + ServiceEcaArtifactInfo curInfo = this.allServiceEcaInfos.get(ecaRule); + if (curInfo == null) { + curInfo = new ServiceEcaArtifactInfo(ecaRule, this); + this.allServiceEcaInfos.put(ecaRule, curInfo); + } + return curInfo; + } + public FormWidgetArtifactInfo getFormWidgetArtifactInfo(String formName, String formLocation) throws GeneralException, IOException, SAXException, ParserConfigurationException { FormWidgetArtifactInfo curInfo = this.allFormInfos.get(formName + formLocation); if (curInfo == null) { diff --git a/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java b/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java index c468fb51fe..1afc1165c9 100644 --- a/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java +++ b/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java @@ -32,9 +32,10 @@ import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.UtilFormatOut; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.minilang.SimpleMethod; -import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.ModelParam; import org.ofbiz.service.ModelService; +import org.ofbiz.service.eca.ServiceEcaRule; +import org.ofbiz.service.eca.ServiceEcaUtil; /** * @@ -96,9 +97,16 @@ public class ServiceArtifactInfo { } } - protected void populateTriggeredServiceEcas() { - // TODO populate serviceEcasTriggeredByThisService and for each the reverse-associate cache in the aif - + protected void populateTriggeredServiceEcas() throws GeneralException { + // populate serviceEcasTriggeredByThisService and for each the reverse-associate cache in the aif + Map> serviceEventMap = ServiceEcaUtil.getServiceEventMap(this.modelService.name); + for (List ecaRuleList: serviceEventMap.values()) { + for (ServiceEcaRule ecaRule: ecaRuleList) { + this.serviceEcasTriggeredByThisService.add(aif.getServiceEcaArtifactInfo(ecaRule)); + // the reverse reference + UtilMisc.addToSetInMap(this, aif.allServiceInfosReferringToServiceEcaRule, ecaRule); + } + } } public ModelService getModelService() {