コード例 #1
0
  public ModelReader(String modelName) throws GenericEntityException {
    this.modelName = modelName;
    entityResourceHandlers = FastList.newInstance();
    resourceHandlerEntities = FastMap.newInstance();
    entityResourceHandlerMap = FastMap.newInstance();

    EntityModelReaderInfo entityModelReaderInfo =
        EntityConfigUtil.getEntityModelReaderInfo(modelName);

    if (entityModelReaderInfo == null) {
      throw new GenericEntityConfException(
          "Cound not find an entity-model-reader with the name " + modelName);
    }

    // get all of the main resource model stuff, ie specified in the entityengine.xml file
    for (Element resourceElement : entityModelReaderInfo.resourceElements) {
      ResourceHandler handler =
          new MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME, resourceElement);
      entityResourceHandlers.add(handler);
    }

    // get all of the component resource model stuff, ie specified in each ofbiz-component.xml file
    for (ComponentConfig.EntityResourceInfo componentResourceInfo :
        ComponentConfig.getAllEntityResourceInfos("model")) {
      if (modelName.equals(componentResourceInfo.readerName)) {
        entityResourceHandlers.add(componentResourceInfo.createResourceHandler());
      }
    }
  }
コード例 #2
0
ファイル: EntityEcaUtil.java プロジェクト: RainerJava/ERP-3
  protected static void readConfig(
      String entityEcaReaderName, Map<String, Map<String, List<EntityEcaRule>>> ecaCache) {
    EntityEcaReaderInfo entityEcaReaderInfo =
        EntityConfigUtil.getEntityEcaReaderInfo(entityEcaReaderName);
    if (entityEcaReaderInfo == null) {
      Debug.logError(
          "BAD ERROR: Could not find entity-eca-reader config with name: " + entityEcaReaderName,
          module);
      return;
    }

    for (Element eecaResourceElement : entityEcaReaderInfo.resourceElements) {
      ResourceHandler handler =
          new MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME, eecaResourceElement);
      addEcaDefinitions(handler, ecaCache);
    }

    // get all of the component resource eca stuff, ie specified in each ofbiz-component.xml file
    for (ComponentConfig.EntityResourceInfo componentResourceInfo :
        ComponentConfig.getAllEntityResourceInfos("eca")) {
      if (entityEcaReaderName.equals(componentResourceInfo.readerName)) {
        addEcaDefinitions(componentResourceInfo.createResourceHandler(), ecaCache);
      }
    }
  }
コード例 #3
0
 public LabelReferences(Delegator delegator, LabelManagerFactory factory) {
   this.delegator = delegator;
   this.labels = factory.getLabels();
   DelegatorElement delegatorInfo = null;
   try {
     delegatorInfo = EntityConfigUtil.getDelegator(delegator.getDelegatorBaseName());
   } catch (GenericEntityConfException e) {
     Debug.logWarning(e, "Exception thrown while getting delegator config: ", module);
   }
   String modelName;
   if (delegatorInfo != null) {
     modelName = delegatorInfo.getEntityModelReader();
   } else {
     modelName = "main";
   }
   // since we do not associate a dispatcher to this DispatchContext, it is important to set a name
   // of an existing entity model reader:
   // in this way it will be possible to retrieve the service models from the cache
   this.dispatchContext = new DispatchContext(modelName, this.getClass().getClassLoader(), null);
   Collection<LabelInfo> infoList = this.labels.values();
   for (LabelInfo labelInfo : infoList) {
     this.labelSet.add(labelInfo.getLabelKey());
   }
   Collection<ComponentConfig> componentConfigs = ComponentConfig.getAllComponents();
   for (ComponentConfig config : componentConfigs) {
     String rootFolder = config.getRootLocation();
     rootFolder = rootFolder.replace('\\', '/');
     if (!rootFolder.endsWith("/")) {
       rootFolder = rootFolder + "/";
     }
     this.rootFolders.add(rootFolder);
   }
 }
コード例 #4
0
ファイル: EntityEcaUtil.java プロジェクト: RainerJava/ERP-3
 public static String getEntityEcaReaderName(String delegatorName) {
   DelegatorInfo delegatorInfo = EntityConfigUtil.getDelegatorInfo(delegatorName);
   if (delegatorInfo == null) {
     Debug.logError(
         "BAD ERROR: Could not find delegator config with name: " + delegatorName, module);
     return null;
   }
   return delegatorInfo.entityEcaReader;
 }
コード例 #5
0
  public static ModelReader getModelReader(String delegatorName) throws GenericEntityException {
    DelegatorInfo delegatorInfo = EntityConfigUtil.getDelegatorInfo(delegatorName);

    if (delegatorInfo == null) {
      throw new GenericEntityConfException(
          "Could not find a delegator with the name " + delegatorName);
    }

    String tempModelName = delegatorInfo.entityModelReader;
    ModelReader reader = readers.get(tempModelName);

    if (reader == null) {
      reader = new ModelReader(tempModelName);
      // preload caches...
      reader.getEntityCache();
      reader = readers.putIfAbsentAndGet(tempModelName, reader);
    }
    return reader;
  }