private TypeOrFeature createTypeOrFeature(String name, boolean isType, boolean aAllAnnotatorFeatures) { TypeOrFeature r = new TypeOrFeature_impl(); r.setType(isType); r.setName(name); if (isType) { r.setAllAnnotatorFeatures(aAllAnnotatorFeatures); } return r; }
String name = nextTof.getName(); TypeOrFeature prevTof = (TypeOrFeature) mergedInputs.get(name); if (prevTof != null) { if (prevTof.isType()) { if (!prevTof.isAllAnnotatorFeatures() && nextTof.isAllAnnotatorFeatures()) mergedInputs.put(name, nextTof); String name = nextTof.getName(); TypeOrFeature prevTof = (TypeOrFeature) mergedOutputs.get(name); if (prevTof != null) { if (prevTof.isType()) { if (!prevTof.isAllAnnotatorFeatures() && nextTof.isAllAnnotatorFeatures()) mergedOutputs.put(name, nextTof); String name = (String) inpsList.nextElement(); TypeOrFeature tof = (TypeOrFeature) mergedInputs.get(name); if (tof.isType()) mergedCapability.addInputType(name, tof.isAllAnnotatorFeatures()); else mergedCapability.addInputFeature(name); String name = (String) outsList.nextElement(); TypeOrFeature tof = (TypeOrFeature) mergedOutputs.get(name); if (tof.isType()) mergedCapability.addOutputType(name, tof.isAllAnnotatorFeatures());
newKey = tORf[i].getName(); if (tORf[i].getName().indexOf( org.apache.uima.collection.impl.cpm.Constants.SHORT_DASH_TERM) > -1) { newKey = StringUtils.replaceAll(tORf[i].getName(), org.apache.uima.collection.impl.cpm.Constants.SHORT_DASH_TERM, org.apache.uima.collection.impl.cpm.Constants.LONG_DASH_TERM); modified = true; if (tORf[i].getName().indexOf( org.apache.uima.collection.impl.cpm.Constants.SHORT_COLON_TERM) > -1) { newKey = StringUtils.replaceAll(tORf[i].getName(), org.apache.uima.collection.impl.cpm.Constants.SHORT_COLON_TERM, org.apache.uima.collection.impl.cpm.Constants.LONG_COLON_TERM); tORf[i].setName(newKey); modified = false;
/** * Gets the type or feature. * * @param a the a * @param name the name * @return the type or feature */ public static TypeOrFeature getTypeOrFeature(TypeOrFeature[] a, String name) { if (null == a) return null; for (int i = 0; i < a.length; i++) { if (a[i].getName().equals(name)) return a[i]; } return null; }
private void addResultTof(TypeOrFeature tof, String[] langs, boolean replace) { String name = tof.getName(); String typeName = null; String shortFeatName = null; int i = name.indexOf(TypeSystem.FEATURE_SEPARATOR); if (i < 0) { typeName = name; rsTypesMap.add(typeName, tof.isAllAnnotatorFeatures(), langs, replace); } else { typeName = name.substring(0, i); shortFeatName = name.substring(i+1); rsTypesMap.add(typeName, shortFeatName, langs, replace); } setCompileNeeded(); }
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); table = newTable(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION); ((GridData) table.getLayoutData()).heightHint = 100; table.setHeaderVisible(true); table.setLinesVisible(true); new TableColumn(table, SWT.NONE).setText("Feature Name"); new TableColumn(table, SWT.NONE).setText("Input"); new TableColumn(table, SWT.NONE).setText("Output"); TableItem item = new TableItem(table, SWT.NONE); item.setText(0, CapabilitySection.ALL_FEATURES); TypeOrFeature tof = AbstractSection.getTypeOrFeature(capability.getInputs(), selectedType .getName()); setChecked(item, 1, null == tof ? false : tof.isAllAnnotatorFeatures()); tof = AbstractSection.getTypeOrFeature(capability.getOutputs(), selectedType.getName()); setChecked(item, 2, null == tof ? false : tof.isAllAnnotatorFeatures()); for (int i = 0; i < allFeatures.length; i++) { item = new TableItem(table, SWT.NONE); item.setText(0, allFeatures[i].getShortName()); setChecked(item, 1, CapabilitySection.isInput(getTypeFeature(allFeatures[i]), capability)); setChecked(item, 2, CapabilitySection.isOutput(getTypeFeature(allFeatures[i]), capability)); } table.removeListener(SWT.Selection, this); table.addListener(SWT.MouseDown, this); // for i / o toggling section.packTable(table); newErrorMessage(composite); return composite; }
/** * Sets the all features. * * @param items Existing array of TypeOrFeature items (input or output) * @param typeName the type name * @param isAllFeatures AllFeatures value * @return the type or feature[] */ private TypeOrFeature[] setAllFeatures(TypeOrFeature[] items, String typeName, boolean isAllFeatures) { TypeOrFeature type = getTypeOrFeature(items, typeName); if (null != type) { type.setAllAnnotatorFeatures(isAllFeatures); return items; } // If get here, case = Type declared as Output(input) or not at all while all Features // declared as Input (output) // Need to add the Type and set the all annotator features value if (isAllFeatures) throw new InternalErrorCDE("invalid state"); return items; }
/** * @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(); }
private static TypeOrFeature[] createTypesOrFeatures(String[] typesOrFeatureNames) { if (typesOrFeatureNames.length == 1 && typesOrFeatureNames[0].equals(TypeCapability.NO_DEFAULT_VALUE)) { return new TypeOrFeature[0]; } else { List<TypeOrFeature> typesOrFeatures = new ArrayList<TypeOrFeature>(); for (String name : typesOrFeatureNames) { TypeOrFeature tof = new TypeOrFeature_impl(); tof.setName(name); if (name.indexOf(":") == -1) { tof.setType(true); } else { tof.setType(false); } typesOrFeatures.add(tof); } return typesOrFeatures.toArray(new TypeOrFeature[typesOrFeatures.size()]); } } }
/** * Type or feature array remove. * * @param a the a * @param s the s * @return the type or feature[] */ public TypeOrFeature[] typeOrFeatureArrayRemove(TypeOrFeature[] a, String s) { TypeOrFeature[] result = new TypeOrFeature[a.length - 1]; for (int i = 0, j = 0; i < a.length; i++) { if (!a[i].getName().equals(s)) { // debug if (j == a.length - 1) throw new InternalErrorCDE("feature or type not found: looking for " + s); result[j++] = a[i]; } } return result; }
/** * Removes the feature. * * @param c the c * @param removeItem the remove item */ private void removeFeature(Capability c, TableTreeItem removeItem) { String shortFeatureName = removeItem.getText(NAME_COL); if (shortFeatureName.equals(ALL_FEATURES)) { if (isInput(removeItem)) { TypeOrFeature tfItem = getTypeOrFeature(c.getInputs(), getFullyQualifiedName(removeItem .getParentItem())); tfItem.setAllAnnotatorFeatures(false); } if (isOutput(removeItem) /* || isUpdate(removeItem) */) { TypeOrFeature tfItem = getTypeOrFeature(c.getOutputs(), getFullyQualifiedName(removeItem .getParentItem())); tfItem.setAllAnnotatorFeatures(false); } } else { String featureNameToRemove = getFullyQualifiedName(removeItem.getParentItem()) + ":" + removeItem.getText(NAME_COL); if (isInput(removeItem)) c.setInputs(typeOrFeatureArrayRemove(c.getInputs(), featureNameToRemove)); if (isOutput(removeItem) /* || isUpdate(removeItem) */) c.setOutputs(typeOrFeatureArrayRemove(c.getOutputs(), featureNameToRemove)); } removeItem.dispose(); }
String name = inputs[i].getName(); if (inputs[i].isType()) { tc = getTypeCapability(name); tc.isInputType = true; if (inputs[i].isAllAnnotatorFeatures()) { fc = getFeatureCapability(tc, ALL_FEATURES); fc.isInputFeature = true; String name = outputs[i].getName(); if (outputs[i].isType()) { tc = getTypeCapability(name); tc.isOutputType = true; if (outputs[i].isAllAnnotatorFeatures()) { fc = getFeatureCapability(tc, ALL_FEATURES); fc.isOutputType = true;
@Override boolean visit(TypeOrFeature i_o) { if (i_o.isType() && i_o.getName().equals(sOldTypeName)) { capabilityChanged[0] = true; i_o.setName(sNewTypeName); } else if (!i_o.isType() && i_o.getName().startsWith(oldTypeName_colon)) { capabilityChanged[0] = true; i_o.setName(sNewTypeName + ':' + i_o.getName().substring(oldTypeName_colon.length())); } return false; } };
/** * @see org.apache.uima.resource.metadata.Capability#addInputType(java.lang.String, * boolean) */ public void addInputType(String aTypeName, boolean aAllAnnotatorFeatures) { TypeOrFeature type = UIMAFramework.getResourceSpecifierFactory().createTypeOrFeature(); type.setType(true); type.setName(aTypeName); type.setAllAnnotatorFeatures(aAllAnnotatorFeatures); TypeOrFeature[] oldArr = getInputs(); TypeOrFeature[] newArr = new TypeOrFeature[oldArr.length + 1]; System.arraycopy(oldArr, 0, newArr, 0, oldArr.length); newArr[newArr.length - 1] = type; setInputs(newArr); }
/** * @see org.apache.uima.resource.metadata.Capability#addInputFeature(java.lang.String) */ public void addInputFeature(String aFeatureName) { TypeOrFeature feat = UIMAFramework.getResourceSpecifierFactory().createTypeOrFeature(); feat.setType(false); feat.setName(aFeatureName); TypeOrFeature[] oldArr = getInputs(); TypeOrFeature[] newArr = new TypeOrFeature[oldArr.length + 1]; System.arraycopy(oldArr, 0, newArr, 0, oldArr.length); newArr[newArr.length - 1] = feat; setInputs(newArr); }
/** 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()); } } }