TypeOrFeature[] oldIOs = (isValidateInputs) ? capabilities[0].getInputs() : capabilities[0] .getOutputs(); Vector validIOs = new Vector(); for (int i = 0; i < oldIOs.length; i++) { capabilities[0].setInputs(newIOs); else capabilities[0].setOutputs(newIOs);
/** * Gets whether this AE is sofa-aware. This is a derived property that cannot be set directly. An * AE is sofa-aware if and only if it declares at least one input sofa or output sofa. * * @return true if this component is sofa-aware, false if it is sofa-unaware. */ public boolean isSofaAware() { Capability[] capabilities = getCapabilities(); if (capabilities != null) { for (int i = 0; i < capabilities.length; i++) { if (capabilities[i].getInputSofas().length > 0 || capabilities[i].getOutputSofas().length > 0) { return true; } } } return false; }
/** * @see org.apache.uima.analysis_engine.ResultSpecification#addCapabilities(org.apache.uima.resource.metadata.Capability[], * boolean) */ public void addCapabilities(Capability[] capabilities, boolean outputs) { if (null == capabilities) { return; } for (Capability capability : capabilities) { TypeOrFeature[] tofs = outputs ? capability.getOutputs() : capability.getInputs(); for (TypeOrFeature tof : tofs) { String typeName = tof.getName(); if (!tof.isType()) { int i = typeName.indexOf(TypeSystem.FEATURE_SEPARATOR); String shortFeatName = typeName.substring(i+1); typeName = typeName.substring(0, i); rsTypesMap.add(typeName, shortFeatName, capability.getLanguagesSupported(), false); } else { rsTypesMap.add(typeName, tof.isAllAnnotatorFeatures(), capability.getLanguagesSupported(), false); } } } setCompileNeeded(); }
/** * Match capabilities to. * * @param capabilities the capabilities * @param search the search * @param isInput the is input * @return true, if successful */ private boolean matchCapabilitiesTo(Capability[] capabilities, Pattern search, boolean isInput) { if (null == search) return true; for (int i = 0; i < capabilities.length; i++) { TypeOrFeature[] typeOrFeatures = isInput ? capabilities[i].getInputs() : capabilities[i] .getOutputs(); if (null != typeOrFeatures) { for (int j = 0; j < typeOrFeatures.length; j++) { if (search.matcher(typeOrFeatures[j].getName()).find()) { return true; } } } } return false; }
String[] prevSofas; if (existingIsInput) { cSets[i].setInputSofas((String[]) Utility.removeElementsFromArray(prevSofas = cSets[i] .getInputSofas(), existingSofaName, String.class)); wasRemoved = prevSofas != cSets[i].getInputSofas(); } else { cSets[i].setOutputSofas((String[]) Utility.removeElementsFromArray(prevSofas = cSets[i] .getOutputSofas(), existingSofaName, String.class)); wasRemoved = prevSofas != cSets[i].getOutputSofas(); cSets[i].setInputSofas(stringArrayAdd(cSets[i].getInputSofas(), dialog.sofaName)); } else { cSets[i].setOutputSofas(stringArrayAdd(cSets[i].getOutputSofas(), dialog.sofaName)); TypeOrFeature typeInput = getTypeOrFeature(c.getInputs(), getFullyQualifiedName(editItem)); c.addInputType(dialog.types[0], true); c.setInputs(typeOrFeatureArrayRemove(c.getInputs(), typeInput)); removeAllFeatItemGui(editItem, INPUT_COL); TypeOrFeature typeOutput = getTypeOrFeature(c.getOutputs(), getFullyQualifiedName(editItem)); c.addOutputType(dialog.types[0], true); getOrCreateAllFeatItem(editItem, OUTPUT_COL, OUTPUT); c.setOutputs(typeOrFeatureArrayRemove(c.getOutputs(), typeOutput)); removeAllFeatItemGui(editItem, OUTPUT_COL);
c.setLanguagesSupported(stringArrayRemove(c.getLanguagesSupported(), removeItem .getText(NAME_COL))); removeItem.dispose(); boolean isInput = INPUT.equals(removeItem.getText(INPUT_COL)); if (isInput) c.setInputSofas((String[]) Utility.removeElementFromArray(c.getInputSofas(), sofaName, String.class)); else c.setOutputSofas((String[]) Utility.removeElementFromArray(c.getOutputSofas(), sofaName, String.class)); removeItem.dispose(); c.setInputs(typeOrFeatureArrayRemove(c.getInputs(), typeNameToRemove)); if (isOutput(removeItem) /* || isUpdate(removeItem) */) c.setOutputs(typeOrFeatureArrayRemove(c.getOutputs(), typeNameToRemove));
Capability entry = (Capability) allList.next(); TypeOrFeature[] entryInps = entry.getInputs(); TypeOrFeature[] entryOuts = entry.getOutputs(); TypeOrFeature tof = (TypeOrFeature) mergedInputs.get(name); if (tof.isType()) mergedCapability.addInputType(name, tof.isAllAnnotatorFeatures()); else mergedCapability.addInputFeature(name); TypeOrFeature tof = (TypeOrFeature) mergedOutputs.get(name); if (tof.isType()) mergedCapability.addOutputType(name, tof.isAllAnnotatorFeatures()); else mergedCapability.addOutputFeature(name);
String[] languages = c.getLanguagesSupported(); if (null != languages) { for (int i = 0; i < languages.length; i++) { String[] inputSofaNames = c.getInputSofas(); String[] outputSofaNames = c.getOutputSofas(); Arrays.sort(inputSofaNames); Arrays.sort(outputSofaNames); TypeOrFeature[] inputs = c.getInputs(); TypeOrFeature[] outputs = c.getOutputs(); typeInfo = new TreeMap();
languages = new String[0]; capability.setLanguagesSupported(languages); mimeTypes = new String[0]; capability.setMimeTypesSupported(mimeTypes); inputSofas = new String[0]; capability.setInputSofas(inputSofas); outputSofas = new String[0]; capability.setOutputSofas(outputSofas); TypeCapability annotation = ReflectionUtil.getAnnotation(componentClass, TypeCapability.class); String[] inputTypesOrFeatureNames = annotation.inputs(); capability.setInputs(createTypesOrFeatures(inputTypesOrFeatureNames)); String[] outputTypesOrFeatureNames = annotation.outputs(); capability.setOutputs(createTypesOrFeatures(outputTypesOrFeatureNames));
/** * Handle add sofa. * * @param selItem the sel item * @param itemKind the item kind */ private void handleAddSofa(TableTreeItem selItem, int itemKind) { if (itemKind == CS) selItem = selItem.getItems()[1]; else if (itemKind == LANG || itemKind == TYPE) selItem = selItem.getParentItem().getItems()[1]; else if (itemKind == LANG_ITEM || itemKind == FEAT || itemKind == SOFA_ITEM) selItem = selItem.getParentItem().getParentItem().getItems()[1]; Capability c = getCapabilityFromTableTreeItem(selItem.getParentItem()); AddSofaDialog dialog = new AddSofaDialog(this, c); if (dialog.open() == Window.CANCEL) return; // dialog.isInput, dialog.sofaName if (dialog.isInput) c.setInputSofas(stringArrayAdd(c.getInputSofas(), dialog.sofaName)); else c.setOutputSofas(stringArrayAdd(c.getOutputSofas(), dialog.sofaName)); TableTreeItem item = new TableTreeItem(selItem, SWT.NONE); setGuiSofaName(item, dialog.sofaName, dialog.isInput); selItem.setExpanded(true); pack04(); sofaMapSection.markStale(); finishAction(); }
/** * Checks if is output. * * @param fullFeatureName the full feature name * @param c the c * @return true, if is output */ public static boolean isOutput(String fullFeatureName, Capability c) { return null != getTypeOrFeature(c.getOutputs(), fullFeatureName); }
/** * Checks if is input. * * @param fullFeatureName the full feature name * @param c the c * @return true, if is input */ public static boolean isInput(String fullFeatureName, Capability c) { return null != getTypeOrFeature(c.getInputs(), fullFeatureName); }
Capability capability = uimaFactory.createCapability(); for (StringTriple typeTriple : desc.getTypeTriples()) { capability.addInputType(typeTriple.getName(), false); capability.addOutputType(typeTriple.getName(), false);
casConsumerDesc.getCasConsumerMetaData().getCapabilities()[0].addInputType("uima.cas.TOP", true); .getAnalysisEngineMetaData().getCapabilities(); for (int i = 0; i < capabilities.length; i++) { TypeOrFeature[] outputs = capabilities[i].getOutputs(); for (int j = 0; j < outputs.length; j++) { if (outputs[j].isType()) {
return; c.setLanguagesSupported(stringArrayAdd(c.getLanguagesSupported(), dialog.getValue()));
/** * Needs view. * * @return true if needsTCas */ private boolean needsView() { if (definedCapabilities == null) { // If Collection Reader and CAS Initilaizer do not declare any output SofAs, // must be sent the default view (meaning whatever's mapped to _InitialView) // for backward compatiblity CasInitializer casIni = ((CollectionReader) collectionReader).getCasInitializer(); if (casIni != null) { definedCapabilities = casIni.getProcessingResourceMetaData().getCapabilities(); } else { definedCapabilities = ((CollectionReader) collectionReader).getProcessingResourceMetaData() .getCapabilities(); } for (int j = 0; j < definedCapabilities.length; j++) { if (definedCapabilities[j].getOutputSofas().length > 0) { needsTCas = false; break; } } } return needsTCas; }
/** * method computeFlowTable create the flow table for faster processing. The flow table includes * the corresponding flow sequence for all languages in the capabilities * * @param aCapabilities * aggregate engine capabilities * @return Map - flow table includes all sequences for all languages */ protected Map<String, List<AnalysisSequenceCapabilityNode>> computeFlowTable(Capability[] aCapabilities) { // create flowTable Map<String, List<AnalysisSequenceCapabilityNode>> flowTable = new HashMap<String, List<AnalysisSequenceCapabilityNode>>(); // get all languages from the capabilities Set<String> languages = new HashSet<String>(); for (Capability capability : aCapabilities) { for (String capabilityLanguage : capability.getLanguagesSupported()) { languages.add(capabilityLanguage); } } // create flow table with sequences for all languages for (String capabilityLanguage : languages) { flowTable.put(capabilityLanguage, computeSequence(capabilityLanguage, aCapabilities)); } return flowTable; }
Capability[] capabilities = ccdesc.getCasConsumerMetaData().getCapabilities(); for (int i = 0; i < capabilities.length; i++) { String[] inputsofas = capabilities[i].getInputSofas(); if (inputsofas.length > 0) requiresTCas = false;
/** * return true if the type has a feature (except all-features) marked as INPUT (OUTPUT). * * @param typeName the type name * @param IO the io * @return true if the type has a feature (except all-features) marked as INPUT (OUTPUT) */ private boolean someFeatureOnType(String typeName, int IO) { // special case for all-features TypeOrFeature[] tofs = (IO == INPUT) ? capability.getInputs() : capability.getOutputs(); // you can remove the "INPUT" or "OUTPUT" designation from a type // even if it has the all-features flag on. String typeNamePlusColon = typeName + ':'; for (int i = 0; i < tofs.length; i++) { if (!tofs[i].isType() && tofs[i].getName().startsWith(typeNamePlusColon)) return true; } return false; }
/** Add this crd's capabilities for other downstream aeds. */ private void addCapabilities(CollectionReaderDescription crd) { for (Capability capability : crd.getCollectionReaderMetaData() .getCapabilities()) { for (TypeOrFeature output : capability.getOutputs()) { // LOG.info("add @TypeCapability: " + output.getName()); outputTypes.add(output.getName()); } } }