public MyExperimentComponent(MyExperimentComponentRegistry componentRegistry, MyExperimentComponentFamily family, License license, String permissionsString, String uri) { super(uri); this.urlString = uri; this.componentRegistry = componentRegistry; this.componentFamily = family; this.permissionsString = permissionsString; this.license = license; annotationTools = new AnnotationTools(); }
public static String getAnnotation(Dataflow dataflow, Class<? extends AbstractTextualValueAssertion> annotation, String defaultValue) { return annotationTools.getAnnotationString(dataflow, annotation, defaultValue); }
@SuppressWarnings("unchecked") public static String getAnnotationString(Annotated<?> annotated, Class annotationClass, String missingValue) { AbstractTextualValueAssertion a = (AbstractTextualValueAssertion) getAnnotation( annotated, annotationClass); if (a == null) { return missingValue; } return a.getText(); }
for (Class<?> c : aTools.getAnnotatingClasses(this)) { String annotationValue = aTools.getAnnotationString(realizingDataflow, c, null); if (annotationValue == null) continue; try { aTools.setAnnotationString(this, c, annotationValue) .doEdit(); } catch (EditException e) {
private Processor createNestingProcessor(List<Edit<?>> editList) { Processor nestingProcessor = edits.createProcessor(uniqueProcessorName( nameField.getText(), currentDataflow)); if (includedProcessors.size() != 1 || !(includedProcessors.get(0) instanceof Processor)) return nestingProcessor; Processor includedProcessor = (Processor) includedProcessors.get(0); for (Class<?> c : at.getAnnotatingClasses(includedProcessor)) { AnnotationBeanSPI annotation = at.getAnnotation(includedProcessor, AbstractTextualValueAssertion.class); if ((annotation != null) && (annotation instanceof AbstractTextualValueAssertion)) editList.add(at.setAnnotationString(nestingProcessor, c, ((AbstractTextualValueAssertion) annotation).getText())); } return nestingProcessor; }
private Dataflow createNestedDataflow(ActionEvent e) { Dataflow nestedDataflow = edits.createDataflow(); ((DataflowImpl) nestedDataflow).setLocalName(nameField.getText()); try { AnnotationTools at = new AnnotationTools(); at.setAnnotationString(nestedDataflow, DescriptiveTitle.class, nameField.getText()).doEdit(); } catch (EditException e2) { logger.error("failed to put annotation on nested dataflow", e2); } return nestedDataflow; }
scrollPanel.setLayout(new BoxLayout(scrollPanel, BoxLayout.Y_AXIS)); panel.setBorder(new EmptyBorder(5, 5, 5, 5)); for (Class<?> c : annotationTools.getAnnotatingClasses(annotated)) { String name = ""; try { String value = annotationTools.getAnnotationString(annotated, c, MISSING_VALUE);
/** * Add the identification of a Dataflow into its identification annotation chain (if necessary) * * @return Whether an identification needed to be added */ public static boolean addDataflowIdentification(Dataflow dataflow, String internalId, Edits edits) { boolean added = false; IdentificationAssertion ia = (IdentificationAssertion) (AnnotationTools.getAnnotation(dataflow, IdentificationAssertion.class)); if ((ia == null) || !ia.getIdentification().equals(internalId)) { IdentificationAssertion newIa = new IdentificationAssertion(); newIa.setIdentification(internalId); try { AnnotationTools.addAnnotation(dataflow, newIa, edits).doEdit(); } catch (EditException e) { added = false; } } return added; }
public void focusLost(FocusEvent e) { String currentValue = area.getText(); if (currentValue.equals("") || currentValue.equals(MISSING_VALUE)) { currentValue = MISSING_VALUE; area.setText(currentValue); } if (!currentValue.equals(oldValue)) { if (currentValue == MISSING_VALUE) { currentValue = ""; } try { Edits edits = EditsRegistry.getEdits(); Dataflow currentDataflow = fileManager.getCurrentDataflow(); List<Edit<?>> editList = new ArrayList<Edit<?>>(); editList.add(annotationTools.setAnnotationString(annotated, annotationClass, currentValue)); if ((annotated == currentDataflow) && (prb.getString(annotationClass.getCanonicalName()).equals("Title")) &&!currentValue.isEmpty()) { editList.add(edits.getUpdateDataflowNameEdit(currentDataflow, sanitiseName(currentValue))); } if (!isStandalone) { ContextualViewComponent.selfGenerated = true; } editManager.doDataflowEdit(currentDataflow, new CompoundEdit(editList)); ContextualViewComponent.selfGenerated = false; } catch (EditException e1) { logger.warn("Can't set annotation", e1); } oldValue = area.getText(); } }
@SuppressWarnings("unchecked") public <T> List<Class<? extends T>> getAnnotationBeanClasses( Class<T> superClass) { List<Class<? extends T>> results = new ArrayList<Class<? extends T>>(); for (Class<? extends AnnotationBeanSPI> annotationBeanClass : getAnnotationBeanClasses()) { if (superClass.isAssignableFrom(annotationBeanClass)) { results.add((Class<? extends T>) annotationBeanClass); } } return results; }
@SuppressWarnings("unchecked") public Iterable<Class<? extends AnnotationBeanSPI>> getAnnotationBeanClasses() { // Mega casting mega trick! Iterable registry = getAnnotationBeanRegistry(); return (Iterable<Class<? extends AnnotationBeanSPI>>) registry; }
public static Edit<?> setAnnotationString(Annotated<?> annotated, Class<?> c, String value, Edits edits) { AbstractTextualValueAssertion a = null; try { logger.info("Setting " + c.getCanonicalName() + " to " + value); a = (AbstractTextualValueAssertion) c.newInstance(); } catch (InstantiationException e) { // TODO Auto-generated catch block logger.error(e); } catch (IllegalAccessException e) { // TODO Auto-generated catch block logger.error(e); } a.setText(value); return (addAnnotation(annotated, a, edits)); }
protected Element annotationsToXML(Annotated<?> annotated) throws JDOMException, IOException { AnnotationTools.pruneAnnotations(annotated, new EditsImpl()); Element result = new Element(ANNOTATIONS, T2_WORKFLOW_NAMESPACE); for (AnnotationChain a : annotated.getAnnotations()) { Element annotationChainElement; if (annotationChainIs21(a)) { annotationChainElement = new Element(ANNOTATION_CHAIN, T2_WORKFLOW_NAMESPACE); } else { annotationChainElement = new Element(ANNOTATION_CHAIN_2_2, T2_WORKFLOW_NAMESPACE); } populateBeanElementFromXStream(a, annotationChainElement); result.addContent(annotationChainElement); } return result; }
@SuppressWarnings("unchecked") public List<Class> getAnnotatingClasses(Annotated annotated) { List<Class> result = new ArrayList<Class>(); for (Class<? extends AbstractTextualValueAssertion> c : getAnnotationBeanClasses(AbstractTextualValueAssertion.class)) { AppliesTo appliesToAnnotation = (AppliesTo) c .getAnnotation(AppliesTo.class); if (appliesToAnnotation == null) { continue; } for (Class<?> target : appliesToAnnotation.targetObjectType()) { if (target.isInstance(annotated)) { result.add(c); } } } return result; }
public static String getAnnotation(Dataflow dataflow, Class<? extends AbstractTextualValueAssertion> annotation, String defaultValue) { return annotationTools.getAnnotationString(dataflow, annotation, defaultValue); }
public MyExperimentComponent(MyExperimentComponentRegistry componentRegistry, MyExperimentComponentFamily family, License license, String permissionsString, String uri) { super(uri); this.urlString = uri; this.componentRegistry = componentRegistry; this.componentFamily = family; this.permissionsString = permissionsString; this.license = license; annotationTools = new AnnotationTools(); }
private Annotated<?> findSuitableAnnotated(Annotated<?> annotatedUnderConsideration, Class<?> c) { String value = annotationTools.getAnnotationString(annotatedUnderConsideration, c, MISSING_VALUE); if (!value.equals(MISSING_VALUE)) { return annotatedUnderConsideration; } if (annotatedUnderConsideration instanceof Processor) { List<? extends Activity<?>> activities = ((Processor) annotatedUnderConsideration).getActivityList(); if (!activities.isEmpty()) { return findSuitableAnnotated(activities.get(0), c); } } if (annotatedUnderConsideration instanceof NestedDataflow) { return findSuitableAnnotated(((NestedDataflow) annotatedUnderConsideration).getNestedDataflow(), c); } return null; }
public MyExperimentComponentFamily( MyExperimentComponentRegistry componentRegistry, License license, MyExperimentSharingPolicy permissions, String uri) throws RegistryException { super(componentRegistry); this.license = license; this.uri = uri; annotationTools = new AnnotationTools(); if (permissions == null) { this.permissionsString = this.getPermissionsString(); } else { this.permissionsString = permissions.getPolicyString(); } if (license == null) { this.license = componentRegistry.getLicenseOnObject(uri); } }
.getComponentRegistry(); String title = annotationTools.getAnnotationString(dataflow, DescriptiveTitle.class, "Untitled");
public MyExperimentComponentFamily( MyExperimentComponentRegistry componentRegistry, License license, MyExperimentSharingPolicy permissions, String uri) throws RegistryException { super(componentRegistry); this.license = license; this.uri = uri; annotationTools = new AnnotationTools(); if (permissions == null) { this.permissionsString = this.getPermissionsString(); } else { this.permissionsString = permissions.getPolicyString(); } if (license == null) { this.license = componentRegistry.getLicenseOnObject(uri); } }