Package org.apache.uima.collection.metadata

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


      } catch ( IOException ioE ) {
         System.err.println( "Couldn't open cpe xml " + args[0] );
         System.err.println( "  " + ioE.getLocalizedMessage() );
         System.exit( 1 );
      }
      CpeDescription cpeDescription = null;
      try {
         cpeDescription = UIMAFramework.getXMLParser().parseCpeDescription( xmlInputSource );
      } catch ( InvalidXMLException ixmlE ) {
         System.err.println( "Couldn't parse cpe xml " + args[0] );
         System.err.println( "  " + ixmlE.getLocalizedMessage() );
View Full Code Here


    }
   
    static public CpeDescriptorModel createInstance (String cpeXmlDescriptorFile)
    {
        try {
            CpeDescription cpeDescription = UIMAFramework.getXMLParser().parseCpeDescription(new XMLInputSource(new File(cpeXmlDescriptorFile)));
            return createInstance (cpeXmlDescriptorFile, cpeDescription);
        } catch (InvalidXMLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
View Full Code Here

        UimaApplication_Impl u = (UimaApplication_Impl) uimaApp;
       
        String cpeXml = resolveUimaXmlDescriptor(uimaApp.getCpeDescriptor());
        if (cpeXml != null && cpeXml.trim().length()>0) {
            u.cpeHref = cpeXml;
            CpeDescription cpeDescription = null;
            try {
                cpeDescription = UIMAFramework.getXMLParser().parseCpeDescription(new XMLInputSource(new File(cpeXml)));
            } catch (InvalidXMLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
View Full Code Here

    public String generateCpeXmlDescriptor (String outputXmlDescriptorFileName, boolean resolve)
                                throws CpeDescriptorException, SAXException, IOException
    {
        StringWriter w = new StringWriter();
        // Create a empty CpeDescription
        CpeDescription cpeDesc = CpeDescriptorFactory.produceDescriptor();

        // Add Collection Reader
        List list = getUimaCollectionReaders();
        if (list != null && list.size() > 0) {
            String aCollectionReaderPath = "";
            CpeCollectionReader cr = null;
            aCollectionReaderPath = ((UimaCollectionReader)list.get(0)).getXmlDescriptor();
            if (resolve) {
                cr = cpeDesc.addCollectionReader(resolveUimaXmlDescriptor(aCollectionReaderPath));
            } else {
                cr = cpeDesc.addCollectionReader(aCollectionReaderPath);
            }

            // Add Configuration Parameter Overrides for CPE
            UimaCollectionReader ucr = (UimaCollectionReader)list.get(0);
            if (ucr.getConfigParamsModel() != null) {
                List cpeOverrideList = ucr.getConfigParamsModel().getCpeParamModelList();
                if (cpeOverrideList != null && cpeOverrideList.size() > 0) {
                    CasProcessorConfigurationParameterSettings settings =
                        CpeDescriptorFactory.produceCasProcessorConfigurationParameterSettings();
                    cr.setConfigurationParameterSettings(settings);
                    for (int k=0; k<cpeOverrideList.size(); ++k) {
                        ConfigParameterModel m = (ConfigParameterModel) cpeOverrideList.get(k);
                        if (m.getCpeValue() != null) {
                            settings.setParameterValue (m.getName(), m.getCpeValue());
                        }
                    }
                }
            }
        }

        // Add CAS Initializer
        list = getUimaCasInitializers();
        if (list != null && list.size() > 0) {
            String aCasInitializerPath = "";
            CpeCollectionReaderCasInitializer ci = null;
            aCasInitializerPath = ((UimaCasInitializer)list.get(0)).getXmlDescriptor();
            if (resolve) {
                ci = cpeDesc.addCasInitializer(resolveUimaXmlDescriptor(aCasInitializerPath));
            } else {
                ci = cpeDesc.addCasInitializer(aCasInitializerPath);
            }
            // Trace.err("Add Cas Init: " + aCasInitializerPath);
            // Add Configuration Parameter Overrides for CPE
            UimaCasInitializer uci = (UimaCasInitializer)list.get(0);
            if (uci.getConfigParamsModel() != null) {
                List cpeOverrideList = uci.getConfigParamsModel().getCpeParamModelList();
                if (cpeOverrideList != null && cpeOverrideList.size() > 0) {
                    CasProcessorConfigurationParameterSettings settings =
                        CpeDescriptorFactory.produceCasProcessorConfigurationParameterSettings();
                    ci.setConfigurationParameterSettings(settings);
                    for (int k=0; k<cpeOverrideList.size(); ++k) {
                        ConfigParameterModel m = (ConfigParameterModel) cpeOverrideList.get(k);
                        if (m.getCpeValue() != null) {
                            settings.setParameterValue (m.getName(), m.getCpeValue());
                        }
                    }
                }
            }
        }

        // Add Cas Processors (AE, Cas Consumer)
        list = getUimaCasProcessors();
        for (int i=0; i<list.size(); ++i) {
            UimaCasProcessor u = (UimaCasProcessor) list.get(i);
            CpeCasProcessor casProc;
//            if (u.getCasProcessorCategory() == UimaCasProcessor.CASPROCESSOR_CAT_SERVICE) {
//                casProc = CpeDescriptorFactory.produceRemoteCasProcessor(u.getInstanceName());
//            } else {
//                casProc = CpeDescriptorFactory.produceCasProcessor(u.getInstanceName());
//            }
            casProc = CpeDescriptorFactory.produceCasProcessor(u.getInstanceName());

            if (resolve) {
                casProc.setDescriptor(resolveUimaXmlDescriptor(u.getXmlDescriptor()));
            } else {
                casProc.setDescriptor(u.getXmlDescriptor());
            }

            // Add Error Handlings
            if (u.getCasProcessorErrorHandling() != null) {
                setCasProcessorErrorHandling(casProc, u.getCasProcessorErrorHandling());
            } else {
                // Set values from default, if any
//              setCasProcessorErrorHandling(casProc, getDefaultCasProcessorSettings().getErrorHandling());                   
            }

            // Set <checkpoint batch="10000"/>
            if (u.getBatchSize() != -1) {
                casProc.setBatchSize(u.getBatchSize());
            } else {
                // Check if default value is defined
                if (getDefaultCasProcessorSettings().getCasProcBatchSize() != -1) {
                    casProc.setBatchSize(getDefaultCasProcessorSettings().getCasProcBatchSize());
                }
            }

            // Add Configuration Parameter Overrides for CPE
            List cpeOverrideList = u.getConfigParamsModel().getCpeParamModelList();
            if (cpeOverrideList != null && cpeOverrideList.size() > 0) {
                CasProcessorConfigurationParameterSettings settings =
                    CpeDescriptorFactory.produceCasProcessorConfigurationParameterSettings();
                casProc.setConfigurationParameterSettings(settings);
                for (int k=0; k<cpeOverrideList.size(); ++k) {
                    ConfigParameterModel m = (ConfigParameterModel) cpeOverrideList.get(k);
                    if (m.getCpeValue() != null) {
                        settings.setParameterValue (m.getName(), m.getCpeValue());
                    }
                }
            }

//          // Add Error Handlings
//CasProcessorErrorHandling errorHandling = u.getCasProcessorErrorHandling();
//          if (errorHandling != null) {

//          casProc.setTimeout(errorHandling.getTimeout().get());
//          }

            // Add to CPE
            cpeDesc.addCasProcessor(casProc);               
        }

        // Set CpeConfiguration from "existing" CpeConfiguration
        CpeConfiguration cpeConfiguration = getCpeConfiguration();
        if (cpeConfiguration == null) {
            // Trace.bug("getCpeConfiguration() == null (NEVER SET ?)");
        } else {
            cpeDesc.getCpeConfiguration().setNumToProcess(cpeConfiguration.getNumToProcess());
            cpeDesc.getCpeConfiguration().setDeployment(cpeConfiguration.getDeployment());
            cpeDesc.getCpeConfiguration().getCheckpoint()
            .setFrequency(cpeConfiguration.getCheckpoint().getFrequency(),
                    cpeConfiguration.getCheckpoint().isTimeBased());
        }

        // Set CpeCasProcessors Settings
        // Trace.trace("************* Set CpeCasProcessors Settings ************");
        if (cpeDesc.getCpeCasProcessors() != null) {
            cpeDesc.getCpeCasProcessors().setPoolSize(cpeCasProcessorsSettings.getCasPoolSize());
        } else {
            // Trace.err("cpeDesc.getCpeCasProcessors() == null");
        }
        cpeDesc.setProcessingUnitThreadCount(cpeCasProcessorsSettings.getProcessingUnitThreadCount());
        ((CpeCasProcessorsImpl) cpeDesc.getCpeCasProcessors()).setDropCasOnException(cpeCasProcessorsSettings.isDropCasOnException());

        FileOutputStream out = null;
        try {
            // Save to file
            if (outputXmlDescriptorFileName != null && outputXmlDescriptorFileName.trim().length() > 0) {
                out = new FileOutputStream (outputXmlDescriptorFileName);
                cpeDesc.toXML(out);
                // Trace.trace("*** write to file: " + outputXmlDescriptorFileName);
            }
            // Return String
            ((CpeDescriptionImpl) cpeDesc).toXML(w);
            // Trace.err(prettyPrintModel(this));
View Full Code Here

    }
    checkpointData = aCheckpointData;
    // enProcSt = new EntityProcessStatusImpl(procTr);
    CPEFactory factory = this.cpeFactory;
    if (factory != null) {
      CpeDescription desc = factory.getCpeDescriptor();
      if (desc != null) {
        CpeCasProcessors proc = desc.getCpeCasProcessors();
        if (proc != null) {
          dropCasOnExceptionPolicy = proc.getDropCasOnException();
        }
      }
    }
View Full Code Here

      System.exit(1);
    }

    // parse CPE descriptor
    System.out.println("Parsing CPE Descriptor");
    CpeDescription cpeDesc = UIMAFramework.getXMLParser()
        .parseCpeDescription(new XMLInputSource(args[0]));
    // instantiate CPE
    System.out.println("Instantiating CPE");
    mCPE = UIMAFramework.produceCollectionProcessingEngine(cpeDesc);
View Full Code Here

public class CpmTestDriver {

  public static void main(String[] args) {
    try {
      // read in the cpe descriptor
      CpeDescription cpeDesc = UIMAFramework.getXMLParser().parseCpeDescription(
              new XMLInputSource("CpeSofaTest/SofaCPE.xml"));
      // instantiate a cpe
      CollectionProcessingEngine cpe = UIMAFramework.produceCollectionProcessingEngine(cpeDesc,
              null);
      // run the cpe
View Full Code Here

   * will have default settings.
   *
   * @return An empty CpeDescription object with default settings
   */
  public static CpeDescription produceDescriptor() {
    CpeDescription descriptor = null;
    descriptor = new CpeDescriptionImpl();

    try {
      descriptor.setCpeConfiguration(produceCpeConfiguration(descriptor));
      descriptor.getCpeConfiguration().setNumToProcess((int) CpeDefaultValues.NUM_TO_PROCESS);
      descriptor.getCpeConfiguration().setDeployment(CpeDefaultValues.DEPLOY_AS);
      descriptor.getCpeConfiguration().setCheckpoint(produceCpeCheckpoint());
      descriptor.getCpeConfiguration().getCheckpoint().setFilePath("");
      descriptor.getCpeConfiguration().getCheckpoint().setFrequency(300000, true);
      descriptor.getCpeConfiguration().setCpeTimer(new CpeTimerImpl(""));
      return descriptor;

    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

    }
    checkpointData = aCheckpointData;
    // enProcSt = new EntityProcessStatusImpl(procTr);
    CPEFactory factory = this.cpeFactory;
    if (factory != null) {
      CpeDescription desc = factory.getCpeDescriptor();
      if (desc != null) {
        CpeCasProcessors proc = desc.getCpeCasProcessors();
        if (proc != null) {
          dropCasOnExceptionPolicy = proc.getDropCasOnException();
        }
      }
    }
View Full Code Here

      } catch ( IOException ioE ) {
         System.err.println( "Couldn't open cpe xml " + args[0] );
         System.err.println( "  " + ioE.getLocalizedMessage() );
         System.exit( 1 );
      }
      CpeDescription cpeDescription = null;
      try {
         cpeDescription = UIMAFramework.getXMLParser().parseCpeDescription( xmlInputSource );
      } catch ( InvalidXMLException ixmlE ) {
         System.err.println( "Couldn't parse cpe xml " + args[0] );
         System.err.println( "  " + ixmlE.getLocalizedMessage() );
View Full Code Here

TOP

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

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.