Exemplo n.º 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());
      }
    }
  }
Exemplo n.º 2
0
  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);
      }
    }
  }