Package org.apache.uima.collection.metadata

Examples of org.apache.uima.collection.metadata.CpeComponentDescriptor


      // if XML tag was specified, configure XmlDetagger annotator and add to CPE
      CpeCasProcessor xmlDetaggerCasProc = null;
      if (xmlTagName != null && xmlTagName.length() > 0) {
        xmlDetaggerCasProc = CpeDescriptorFactory.produceCasProcessor("XmlDetagger");
        CpeComponentDescriptor cpeComponentDescriptor =
          CpeDescriptorFactory.produceComponentDescriptor(XmlDetagger.getDescriptorURL().toString());
        xmlDetaggerCasProc.setCpeComponentDescriptor(cpeComponentDescriptor);
        CasProcessorConfigurationParameterSettings detaggerSettings = CpeDescriptorFactory
                .produceCasProcessorConfigurationParameterSettings();
        xmlDetaggerCasProc.setConfigurationParameterSettings(detaggerSettings);
        detaggerSettings.setParameterValue(XmlDetagger.PARAM_TEXT_TAG, xmlTagName);
        xmlDetaggerCasProc.setMaxErrorCount(0);
        cpeDesc.addCasProcessor(xmlDetaggerCasProc);
      }

      // add user's AE to CPE
      CpeCasProcessor casProc = CpeDescriptorFactory.produceCasProcessor("UserAE");
      CpeComponentDescriptor cpeComponentDescriptor =
        CpeDescriptorFactory.produceComponentDescriptor(aeSpecifierFile.getAbsolutePath());
      casProc.setCpeComponentDescriptor(cpeComponentDescriptor);
      casProc.setMaxErrorCount(0);
      cpeDesc.addCasProcessor(casProc);
View Full Code Here


   *
   * @param aDescriptorPath
   */
  public static CpeComponentDescriptor produceComponentDescriptor(String aPath) {

    CpeComponentDescriptor componentDescriptor = new CpeComponentDescriptorImpl();
    CpeInclude include = new CpeIncludeImpl();
    include.set(aPath);
    componentDescriptor.setInclude(include);
    return componentDescriptor;
  }
View Full Code Here

   *          path to the descriptor
   * @throws CpeDescriptorException
   */
  public void setDescriptor(String aDescriptorPath) throws CpeDescriptorException {
    if (descriptor == null) {
      CpeComponentDescriptor comp_desc = CpeDescriptorFactory
              .produceComponentDescriptor(aDescriptorPath);
      this.setCpeComponentDescriptor(comp_desc);
    } else {
      descriptor.getInclude().set(aDescriptorPath);
    }
View Full Code Here

    URL descUrl = materializeDescriptor(aDesc).toURI().toURL();

    CpeInclude cpeInclude = getResourceSpecifierFactory().createInclude();
    cpeInclude.set(descUrl.toString());

    CpeComponentDescriptor ccd = getResourceSpecifierFactory().createDescriptor();
    ccd.setInclude(cpeInclude);

    CpeIntegratedCasProcessor proc = produceCasProcessor(key);
    proc.setCpeComponentDescriptor(ccd);
    proc.setAttributeValue(CpeDefaultValues.PROCESSING_UNIT_THREAD_COUNT, 1);
    proc.setActionOnMaxError(ACTION_ON_MAX_ERROR);
View Full Code Here

   *          path to the descriptor
   * @throws CpeDescriptorException tbd
   */
  public void setDescriptor(String aDescriptorPath) throws CpeDescriptorException {
    if (descriptor == null) {
      CpeComponentDescriptor comp_desc = CpeDescriptorFactory
              .produceComponentDescriptor(aDescriptorPath);
      this.setCpeComponentDescriptor(comp_desc);
    } else {
      descriptor.getInclude().set(aDescriptorPath);
    }
View Full Code Here

   * @param aPath The path to the the CPE component Descriptor
   * @return the CPE Component Description
   */
  public static CpeComponentDescriptor produceComponentDescriptor(String aPath) {

    CpeComponentDescriptor componentDescriptor = new CpeComponentDescriptorImpl();
    CpeInclude include = new CpeIncludeImpl();
    include.set(aPath);
    componentDescriptor.setInclude(include);
    return componentDescriptor;
  }
View Full Code Here

        }
        boolean testIt = false; // FOR TESTING
        if (testIt && collRdrs != null && collRdrs.length>0) {
            for (int i=0; i<collRdrs.length; ++i) {
                // Create a NEW UimaCollectionReader for its Xml descriptor
                CpeComponentDescriptor cpeComponentDescriptor = collRdrs[i].getDescriptor();
                String xml = null;
                if (cpeComponentDescriptor.getInclude() != null) {
                    xml = cpeComponentDescriptor.getInclude().get();
                } else if (cpeComponentDescriptor.getImport() != null) {
                    xml = cpeComponentDescriptor.getImport().getLocation();
                    if (xml == null) {
                        xml = cpeComponentDescriptor.getImport().getName();
                    }
                }
                if (xml == null || xml.trim().length() == 0) {
                    // EMPTY Collection Reader
                    // Trace.err("EMPTY Collection Reader");
                    continue;
                }
                String newFileLocation = xml;
                String resolvedFileName = UimaApplication_Impl.resolveUimaXmlDescriptor(xml);
                if (resolvedFileName == null) {
                    // Cannot resolve
                    // Trace.err("cannot resolve file: " + resolvedFileName);                   
                } else {
                    File f = new File(resolvedFileName);
                    if ( !f.isAbsolute() ) {
                        // Relative path
                        if ( ! f.exists() ) {
                            // Can NOT find file.
                            // Try to find it within CURRENT DIRECTORY
                            f = new File (currentDir, resolvedFileName);
                            if ( ! f.exists() ) {
                                Trace.trace("*** ERROR: Cannot find file: " + resolvedFileName);
                                error = STATUS_DEPLOYMENT_NODE_ERROR;
                                details = STATUS_DETAILS_FILE_NOT_FOUND;
                            }
                            resolvedFileName = f.getAbsolutePath();
                            newFileLocation = resolvedFileName;
                        }
                        // Trace.trace("+++ New xml:" + resolvedFileName);
                    }
                }
                UimaCollectionReader u = UimaCollectionReader.createUimaCasProcessor (collRdrs[i],
                        newFileLocation/*resolvedFileName*/, this);
                // Need to check duplication
//                UimaCasProcessor u = getUimaCasProcessor(collRdrs[i].getName());
//                if (u != null) {
//                    UimaCasProcessor_impl.createUimaCasProcessorFrom(u, casProcs[i], specifier, this);
//                } else {
//                    u = UimaCasProcessor_impl.createUimaCasProcessor(casProcs[i], specifier, this);
//                    uimaCasProcessors.add(u);
//                }
               
                if (error > 0) {
                    u.setStatus(error);
                    u.setStatusDetails(details);
                }
                uimaCollectionReaders.add(u);               
            } // for
           
            // ONLY 1 Cas Initializer is allowed (Also true for Collection Reader)
            CpeCollectionReaderCasInitializer casInit = null;
            try {
                casInit = collRdrs[0].getCasInitializer();
            } catch (CpeDescriptorException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (casInit != null) {
                // Create a NEW UimaCasInitializer for its Xml descriptor
                String xml = casInit.getDescriptor().getInclude().get();
                if (xml == null || xml.trim().length() == 0) {
                    // EMPTY Cas Initializer
                    // Trace.err("EMPTY Cas Initializer");
                } else {
                    String newFileLocation = xml;
                    String resolvedFileName = resolveUimaXmlDescriptor(xml);
                    File f = new File(resolvedFileName);
                    error = 0;
                    details = 0;
                    if ( !f.isAbsolute() ) {
                        // Relative path
                        if ( ! f.exists() ) {
                            // Can NOT find file.
                            // Try to find it within CURRENT DIRECTORY
                            f = new File (currentDir, resolvedFileName);
                            if ( ! f.exists() ) {
                                // Trace.trace("*** ERROR: Cannot find file: " + resolvedFileName);
                                error = STATUS_DEPLOYMENT_NODE_ERROR;
                                details = STATUS_DETAILS_FILE_NOT_FOUND;
                            }
                            resolvedFileName = f.getAbsolutePath();
                            newFileLocation = resolvedFileName;
                        }
                        // Trace.trace("+++ New xml:" + resolvedFileName);
                    }
       
                    UimaCasInitializer u = UimaCasInitializer.createUimaCasProcessor (casInit,
                            newFileLocation/*resolvedFileName*/, this);
                    if (error > 0) {
                        u.setStatus(error);
                        u.setStatusDetails(details);
                    }
                    uimaCasInitializers.add(u);    
                }
            }
        }
       
        /*****************************************************************/
        if (cpeCasProcessorsSettings == null) {
            cpeCasProcessorsSettings = new CpeCasProcessorsSettings();
        }
        try {
            cpeCasProcessorsSettings.setCasPoolSize(((CpeCasProcessorsImpl) cpeDescription.getCpeCasProcessors()).getPoolSize());
            // Cannot get processingUnitThreadCount
            cpeCasProcessorsSettings.setDropCasOnException(((CpeCasProcessorsImpl) cpeDescription.getCpeCasProcessors()).getDropCasOnException());
        } catch (CpeDescriptorException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
       
        // CPE Cas Processors
        CpeCasProcessor[] casProcs = null;
        try {
            casProcs = cpeDescription.getCpeCasProcessors().getAllCpeCasProcessors();
        } catch (CpeDescriptorException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }           
        if (casProcs == null) {
            // Empty Cpe Descriptor
            return ;
        }

        // Get list of CpeCasProcessor which can be an AE or a Cas Consumer
        // For each CpeCasProcessor, get its type system (insert in cpeModel.typeSystemList)
        // cpeModel.cpeCasProcessorModelList = new ArrayList();
//      List    specifierList = new ArrayList();
//      List    aeList       = new ArrayList();
//      List    consumerList = new ArrayList();
        // cpeModel.typeSystemList = new ArrayList();
        for (int i=0; i < casProcs.length; i++) {
            CpeComponentDescriptor cpeComponentDescriptor = casProcs[i].getCpeComponentDescriptor();
            String newFileLocation = null;
            if (cpeComponentDescriptor.getInclude() != null) {
                newFileLocation = cpeComponentDescriptor.getInclude().get();
            } else if (cpeComponentDescriptor.getImport() != null) {
                newFileLocation = cpeComponentDescriptor.getImport().getLocation();
                if (newFileLocation == null) {
                    newFileLocation = cpeComponentDescriptor.getImport().getName();
                }
            }
            String specifierFile = resolveUimaXmlDescriptor(newFileLocation);

            ResourceSpecifier specifier = null;
View Full Code Here

   *
   * @param aPath
   */
  public static CpeComponentDescriptor produceComponentDescriptor(String aPath) {

    CpeComponentDescriptor componentDescriptor = new CpeComponentDescriptorImpl();
    CpeInclude include = new CpeIncludeImpl();
    include.set(aPath);
    componentDescriptor.setInclude(include);
    return componentDescriptor;
  }
View Full Code Here

      // if XML tag was specified, configure XmlDetagger annotator and add to CPE
      CpeCasProcessor xmlDetaggerCasProc = null;
      if (xmlTagName != null && xmlTagName.length() > 0) {
        xmlDetaggerCasProc = CpeDescriptorFactory.produceCasProcessor("XmlDetagger");
        CpeComponentDescriptor cpeComponentDescriptor =
          CpeDescriptorFactory.produceComponentDescriptor(XmlDetagger.getDescriptorURL().toString());
        xmlDetaggerCasProc.setCpeComponentDescriptor(cpeComponentDescriptor);
        CasProcessorConfigurationParameterSettings detaggerSettings = CpeDescriptorFactory
                .produceCasProcessorConfigurationParameterSettings();
        xmlDetaggerCasProc.setConfigurationParameterSettings(detaggerSettings);
        detaggerSettings.setParameterValue(XmlDetagger.PARAM_TEXT_TAG, xmlTagName);
        xmlDetaggerCasProc.setMaxErrorCount(0);
        cpeDesc.addCasProcessor(xmlDetaggerCasProc);
      }

      // add user's AE to CPE
      CpeCasProcessor casProc = CpeDescriptorFactory.produceCasProcessor("UserAE");
      CpeComponentDescriptor cpeComponentDescriptor =
        CpeDescriptorFactory.produceComponentDescriptor(aeSpecifierFile.getAbsolutePath());
      casProc.setCpeComponentDescriptor(cpeComponentDescriptor);
      casProc.setMaxErrorCount(0);
      cpeDesc.addCasProcessor(casProc);
View Full Code Here

   *          path to the descriptor
   * @throws CpeDescriptorException
   */
  public void setDescriptor(String aDescriptorPath) throws CpeDescriptorException {
    if (descriptor == null) {
      CpeComponentDescriptor comp_desc = CpeDescriptorFactory
              .produceComponentDescriptor(aDescriptorPath);
      this.setCpeComponentDescriptor(comp_desc);
    } else {
      descriptor.getInclude().set(aDescriptorPath);
    }
View Full Code Here

TOP

Related Classes of org.apache.uima.collection.metadata.CpeComponentDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.