Examples of UimaCollectionReader


Examples of org.apache.uima.cpe.model.UimaCollectionReader

            } 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) {
View Full Code Here

Examples of org.apache.uima.cpe.model.UimaCollectionReader

                            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;
            // Check for file existence
            if ( specifierFile == null || specifierFile.trim().length() == 0 ) {
                // Trace.err("EMPTY (no xml desc) Cas Processor " + casProcs[i].getName());
                continue;
            } else {
                File f = new File(specifierFile);
                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, specifierFile);
                        if ( ! f.exists() ) {
                            // Trace.err("*** ERROR: Cannot find file: " + specifierFile);
                            error = STATUS_DEPLOYMENT_NODE_ERROR;
                            details = STATUS_DETAILS_FILE_NOT_FOUND;
                            // continue;
                        }
                        specifierFile = f.getAbsolutePath();
                        newFileLocation = specifierFile;
                    }
                } else {
                    // Absolute Path
                    if ( ! f.exists() ) {
                        // Trace.err ("Cannot find xml file for " + casProcs[i].getName()
                        //           + ": " + specifierFile);
                        error = STATUS_DEPLOYMENT_NODE_ERROR;
                        details = STATUS_DETAILS_FILE_NOT_FOUND;
                        // continue;
                    }                   
                }

                if (error == 0) {
                    // No error.
                    try {
                        specifier = UIMAFramework.getXMLParser().
                                    parseResourceSpecifier(new XMLInputSource(specifierFile));
                    } catch (InvalidXMLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        continue;
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        continue;
                    }
                }
            }
//            if (specifier != null) {
//                specifierList.add(specifier);
//   
//                if (isCasConsumerSpecifier(specifier)) {
//                    consumerList.add(specifier);
//                } else {
//                    aeList.add(specifier);
//                }
//            }
            // Need to check duplication
            UimaCasProcessor u = getUimaCasProcessor(casProcs[i].getName());
            if (u != null) {
                Trace.err("Duplicate with CasProcessor from CPE: " + casProcs[i].getName());
                // Should we call the following code ?
                if (testIt) {
                    UimaCasProcessor_impl.createUimaCasProcessorFrom(u, casProcs[i], specifier, this);
                } else {
                    u.setCpeCasProcessor(casProcs[i]);
                }
            } else {
                u = UimaCasProcessor_impl.createUimaCasProcessor(casProcs[i], specifier, this);
                uimaCasProcessors.add(u);
            }
            if (error > 0) {
                u.setStatus(error);
                u.setStatusDetails(details);
            }
            // File path may be changed
            // ((AbstractUimaCasProcessor) u).setXmlDescriptor(specifierFile);
            ((AbstractUimaCasProcessor) u).setXmlDescriptor(newFileLocation);

            // Get CasProcessorErrorHandling
            if (cpeDefaultErrorHandling == null) {
                // Trace.bug("NO pre-setting for cpeDefaultErrorHandling");
                cpeDefaultErrorHandling = CpeDescriptorFactory.produceCasProcessorErrorHandling();
            }
            // printErrorHandling(cpeDefaultErrorHandling);

            if ( ! compareWithCpeDefaultErrorHandling(casProcs[i].getErrorHandling()) ) {
                // Not the same values as CPE defaults
                u.setCasProcessorErrorHandling(casProcs[i].getErrorHandling());
            }
            u.setBatchSize(casProcs[i].getBatchSize());

            // Get type system
            // cpeModel.typeSystemList.add(getTypeSystemDescription(specifier));
        } // for   
    } // addCpeDescription
View Full Code Here

Examples of org.apache.uima.cpe.model.UimaCollectionReader

        // CPE BUG!!! Need to call CpeDescriptorFactory.produceDescriptor();
//        CpeDescription cpeDesc = CpeDescriptorFactory.produceDescriptor();
       
        // Trace.trace("xmlizableXmlFile:" + xmlizableXmlFile);
        if (xmlizable instanceof CollectionReaderDescription) {
            UimaCollectionReader u = UimaCollectionReader
            .createUimaCasProcessor ((CollectionReaderDescription) xmlizable,
                    xmlizableXmlFile, this);
            uimaCollectionReaders.add(u);   
            component = u;
        } else if (xmlizable instanceof CasInitializerDescription) {
            // Trace.err("CasInitializerDescription");
            UimaCasInitializer ci = UimaCasInitializer
            .createUimaCasProcessor ((CasInitializerDescription) xmlizable,
                    xmlizableXmlFile, this);
            uimaCasInitializers.add(ci);               
            component = ci;
        } else if (xmlizable instanceof CpeDescription) {
            addCpeDescription(xmlizableXmlFile, (CpeDescription) xmlizable);
            component = this;
        } else {
            CpeCasProcessor cpeCasProcessor;
//            if (xmlizable instanceof URISpecifier) {
//                cpeCasProcessor = CpeDescriptorFactory.produceRemoteCasProcessor("xmlizableXmlFile");
//            } else {
//                cpeCasProcessor = CpeDescriptorFactory.produceCasProcessor("xmlizableXmlFile");
//            }
            cpeCasProcessor = CpeDescriptorFactory.produceCasProcessor("xmlizableXmlFile");
            cpeCasProcessor.setDescriptor(xmlizableXmlFile);
            UimaCasProcessor u = UimaCasProcessor_impl.createUimaCasProcessor(cpeCasProcessor,
                    xmlizable, this);
            uimaCasProcessors.add(u);
            // Reset cpeCasProcessor's name
            cpeCasProcessor.setName(u.getInstanceName());
            component = u;
        }

        return component;
    } // addXMLizable
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.