Construct model Annotations for each component.

    Annotation formats follow guidelines at http://identifiers.org/.
971721
def get_annotation(component, db_name, db_ref):
    
    url = get_identifiers_url(db_name, db_ref)
    if not url:
        return None
    subj = component
    ann = Annotation(subj, url, 'is')
    return ann
401753
protected void buildConstructorWithFields(ClassVisitor cw,
                                              ClassDefinition classDef,
                                              Collection<FieldDefinition> fieldDefs) {


        Type[] params = new Type[fieldDefs.size()];
        int index = 0;
        for ( FieldDefinition field : fieldDefs ) {
            params[index++] = Type.getType( BuildUtils.getTypeDescriptor( field.getTypeName() ) );
        }

        MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
                "<init>",
                Type.getMethodDescriptor( Type.VOID_TYPE,
                        params ),
                null,
                null );
        mv.visitCode();
        Label l0 = null;
        if ( this.debug ) {
            l0 = new Label();
            mv.visitLabel( l0 );
        }

        fieldConstructorStart( mv, classDef, fieldDefs );

        mv.visitInsn( Opcodes.RETURN );
        Label l1 = null;
        if ( this.debug ) {
            l1 = new Label();
            mv.visitLabel( l1 );
            mv.visitLocalVariable( "this",
                    BuildUtils.getTypeDescriptor( classDef.getClassName() ),
                    null,
                    l0,
                    l1,
                    0 );
            for ( FieldDefinition field : classDef.getFieldsDefinitions() ) {
                Label l11 = new Label();
                mv.visitLabel( l11 );
                mv.visitLocalVariable( field.getName(),
                        BuildUtils.getTypeDescriptor( field.getTypeName() ),
                        null,
                        l0,
                        l1,
                        0 );
            }
        }
        mv.visitMaxs( 0,
                0 );
        mv.visitEnd();

    }
690814
function initFields () {
    // skip if no model
    if (!this.model) {
        return
    }
    // if not fields list was passed in args then add all model properties
    if (!this.fields.length && this.model.schemaData) {
        // get data properites from schema
        var properties = this.model.schemaData.properties
        // add each property from data schema as form field
        _.each(properties, (schema, property) => {
            this.fields.push(property)
        })
    }
    // iterate over fields building spec based on args and schema
    this.fields = _.map(this.fields, field => {
        // field group
        if (Array.isArray(field)) {
            // build spec for each field in group
            field = _.map(field, field => initField(this, field))
            // set correct width units for fields
            setUnits(this, field)
        }
        // individual field
        else {
            field = initField(this, field)
        }
        // return field specification
        return field
    })
}
553938
private ImmutableSet<ASTAnnotation> getAnnotations(Annotation[] annotations) {

        ImmutableSet.Builder<ASTAnnotation> astAnnotationBuilder = ImmutableSet.builder();

        for (Annotation annotation : annotations) {
            astAnnotationBuilder.add(getAnnotation(annotation));
        }

        return astAnnotationBuilder.build();
    }
1358198
def make_annotation(self):
        """"""
        annotation = dict()

        # Put all properties of the action object into the annotation
        for item in dir(self):
            if len(item) > 0 and item[0] != '_' and \
                    not inspect.ismethod(getattr(self, item)):
                annotation[item] = getattr(self, item)

        return annotation
1055795
function Annotations( parent ) {

	// INSTANCE ATTRIBUTES //

	this._parent = parent;
	this._root = undefined;
	this._children = {};
	this._config = {
		'position': {
			'left': 0,
			'top': 0
		}
	};

	// REGISTER //
	if ( parent._config.hasOwnProperty( 'annotations' )  ) {
		parent._config.annotations.push( this._config );
	} else {
		parent._config.annotations = [ this._config ];
	}
	if ( parent._children.hasOwnProperty( 'annotations' ) ) {
		parent._children.annotations.push( this );
	} else {
		parent._children.annotations = [ this ];
	}

	return this;
}
395351
def _extend_component_definitions(self, graph):
        
        for def_uri, comp_def in self._components.items():
            # Store created components indexed for later lookup
            component_index = {}
            identity = URIRef(def_uri)

            # Get components
            for comp in graph.triples((identity, SBOL.component, None)):
                comp_identity = comp[2]
                ci = self._get_rdf_identified(graph, comp_identity)
                ci['maps_to'] = self._get_triplet_value(graph, comp_identity, SBOL.mapTo)
                ci['access'] = self._get_triplet_value(graph, comp_identity, SBOL.access)

                component_comp_def = self._get_triplet_value(graph, comp_identity, SBOL.definition)
                ci['definition'] = self._components[component_comp_def]

                c = Component(**ci)
                component_index[ci['identity']] = c
            self._components[def_uri].components = list(component_index.values())

            # Get sequence annotations
            if (identity, SBOL.sequenceAnnotation, None) in graph:
                find_annotation_using = (identity, SBOL.sequenceAnnotation, None)
            else:
                find_annotation_using = (identity, SBOL.SequenceAnnotation, None)
            sequence_annotations = []
            for seq_annot in graph.triples(find_annotation_using):
                seq_identity = seq_annot[2]
                sa = self._get_rdf_identified(graph, seq_identity)
                component_to_use = self._get_triplet_value(graph, seq_identity, SBOL.component)
                sa['component'] = component_index[component_to_use]
                sa['roles'] = self._get_triplet_value_list(graph, seq_identity, SBOL.role)
                locations = []
                for loc in graph.triples((seq_identity, SBOL.location, None)):
                    loc_identity = loc[2]
                    location = self._get_rdf_identified(graph, loc_identity)
                    location['orientation'] = self._get_triplet_value(graph, loc_identity,
                                                                      SBOL.orientation)
                    location_type = URIRef(self._get_triplet_value(graph, loc_identity, RDF.type))
                    if location_type == SBOL.Range:
                        location['start'] = self._get_triplet_value(graph, loc_identity, SBOL.start)
                        location['end'] = self._get_triplet_value(graph, loc_identity, SBOL.end)
                        locations.append(Range(**location))
                    elif location_type == SBOL.Cut:
                        location['at'] = self._get_triplet_value(graph, loc_identity, SBOL.at)
                        locations.append(Cut(**location))
                    else:
                        locations.append(GenericLocation(**location))
                sa_obj = SequenceAnnotation(locations=locations, **sa)
                sequence_annotations.append(sa_obj)
            self._components[def_uri].sequence_annotations = sequence_annotations

            # Get sequence constraints
            if (identity, SBOL.sequenceConstraint, None) in graph:
                find_constraint_using = (identity, SBOL.sequenceConstraint, None)
            else:
                find_constraint_using = (identity, SBOL.SequenceConstraint, None)
            sequence_constraints = []
            for seq_constraint in graph.triples(find_constraint_using):
                seq_identity = seq_constraint[2]
                sc = self._get_rdf_identified(graph, seq_identity)
                sc['restriction'] = self._get_triplet_value(graph, seq_identity, SBOL.restriction)
                subject_id = self._get_triplet_value(graph, seq_identity, SBOL.subject)
                sc['subject'] = component_index[subject_id]
                object_id = self._get_triplet_value(graph, seq_identity, SBOL.object)
                # Object is a reserved word so call it obj to prevent clashes
                sc['obj'] = component_index[object_id]
                sc_obj = SequenceConstraint(**sc)
                sequence_constraints.append(sc_obj)
            self._components[def_uri].sequence_constraints = sequence_constraints
496610
protected String[] buildAnnotationConstraintParameters(Annotation annotation) {
		
		// Si l'annotation est nulle
		if(annotation == null) return null;
		
		// Si l'annotation est de type @AuthorizedValues
		if(annotation instanceof AuthorizedValues) return new String[] { Arrays.toString(((AuthorizedValues) annotation).values()) };
		
		// Si l'annotation est de type @Interval
		if(annotation instanceof Interval) return new String[] { Double.toString(((Interval) annotation).min()), Double.toString(((Interval) annotation).max()) };
		
		// Si l'annotation est de type @Length
		if(annotation instanceof Length) return new String[] { Integer.toString(((Length) annotation).min()), Integer.toString(((Length) annotation).max()) };
		
		// valeur par defaut
		return null;
	}
452957
private void applyDefinitionComponent(MarkupDocBuilder markupDocBuilder, String definitionName, Model model) {
        definitionComponent.apply(markupDocBuilder, DefinitionComponent.parameters(
                definitionName,
                model,
                2));
    }
408140
def build_model_classes(metadata):
    """"""
    i = importlib.import_module(metadata)
    env = get_jinja_env()
    model_template = env.get_template('model.py.jinja2')
    for model in i.models:
        with open(model_path(model.name.lower()), 'w') as t:
            t.write(model_template.render(model_md=model))
601211
private void loadAnnotateParameters() {
    annotateParser.addArgument("-m", "--model").required(true)
        .help("Pass the model to do the tagging as a parameter.\n");
    annotateParser.addArgument("--clearFeatures").required(false)
        .choices("yes", "no", "docstart").setDefault(Flags.DEFAULT_FEATURE_FLAG)
        .help(
            "Reset the adaptive features every sentence; defaults to 'no'; if -DOCSTART- marks"
                + " are present, choose 'docstart'.\n");
    annotateParser.addArgument("-l", "--language").required(false)
        .choices("ca", "de", "en", "es", "eu", "fr", "gl", "it", "nl", "pt",
            "ru")
        .help(
            "Choose language; it defaults to the language value in incoming NAF file.\n");
    annotateParser.addArgument("-o", "--outputFormat").required(false)
        .choices("conll03", "conll02", "naf", "opennlp")
        .setDefault(Flags.DEFAULT_OUTPUT_FORMAT)
        .help("Choose output format; it defaults to NAF.\n");
    annotateParser.addArgument("--lexer").choices("numeric")
        .setDefault(Flags.DEFAULT_LEXER).required(false)
        .help("Use lexer rules for NERC tagging; it defaults to false.\n");
    annotateParser.addArgument("--dictTag").required(false)
        .choices("tag", "post").setDefault(Flags.DEFAULT_DICT_OPTION).help(
            "Choose to directly tag entities by dictionary look-up; if the 'tag' option is chosen, "
                + "only tags entities found in the dictionary; if 'post' option is chosen, it will "
                + "post-process the results of the statistical model.\n");
    annotateParser.addArgument("--dictPath").required(false)
        .setDefault(Flags.DEFAULT_DICT_PATH).help(
            "Provide the path to the dictionaries for direct dictionary tagging; it ONLY WORKS if --dictTag "
                + "option is activated.\n");
  }
306261
void generateValidationChecks(
            final CtClass ctClass,
            final StringBuilder validationChecksCode,
            final StringBuilder staticInitializerCode,
            final List<String> staticFields) {

        for (final CtField ctField : ctClass.getDeclaredFields()) {
            for (final Object annotationObject : ctField.getAvailableAnnotations()) {
                final Annotation annotation = (Annotation) annotationObject;
                if (ANNOTATIONS.contains(annotation.annotationType())) {
                    final Constraint constraint = annotation.annotationType().getAnnotation(Constraint.class);
                    final Class<? extends AnnotationCheck<? extends Annotation>> checkClass = constraint.checkWith();
                    final String checkType = checkClass.getName();
                    final String checkName = getCheckName(ctField.getName(), checkType);
                    final String fieldName = ctField.getName();

                    // Define the member for the check
                    staticFields.add(generateCheckFieldDeclaration(checkType, checkName));

                    // Define the member for the field context
                    staticFields.add(generateFieldContextDeclaration(ctClass.getName(), checkName, fieldName));

                    // Write the check initializer code
                    staticInitializerCode.append(
                            generateCheckInitializer(
                                    ctClass.getName(),
                                    checkName,
                                    fieldName,
                                    annotation.annotationType().getName()));

                    // Write the validation code
                    validationChecksCode.append(generateValidation(
                            annotation,
                            checkType,
                            checkName,
                            fieldName));
                }
            }
        }
    }
739056
private void loadEngines() {
        try {
            ClassLoader cl = ModelExtractors.class.getClassLoader();
            Enumeration<URL> resources = cl.getResources(PROPERTIES);
            while (resources.hasMoreElements()) {
                URL url = resources.nextElement();
                Properties props = new Properties();
                props.load(url.openStream());
                for (Map.Entry<Object, Object> entry : props.entrySet()) {
                    String className = (String) entry.getKey();
                    String[] extensions = ((String) entry.getValue()).split(",");
                    loadAndRegisterEngine(className, extensions);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
1000329
private void populateAnnotations(Collection<Annotation> annotations) {
        for (Annotation each : annotations) {
            this.annotations.put(each.annotationType(), each);
        }
    }
312654
private List<Annotation> buildDeclaredAnnotationList(final Annotation annotation) {
        final List<Annotation> list = Arrays.stream(annotation.annotationType().getDeclaredAnnotations())
                .collect(Collectors.toList());
        list.add(annotation);
        return list;
    }
252904
def get_annotations(self):
        '''
        
        '''
        rule = getConstant('registration__orgRule')

        # Initialize with null values that get filled in based on the logic below.
        annotations = {
            'nullParam': Case(default_value=None,output_field=IntegerField()),
            'paramOne': Case(default_value=None,output_field=IntegerField()),
            'paramTwo': Case(default_value=None,output_field=IntegerField()),
        }

        if rule == 'SessionFirst':
            annotations.update({
                'nullParam': Case(
                    When(session__startTime__isnull=False, then=0),
                    When(month__isnull=False, then=1),
                    default_value=2,
                    output_field=IntegerField()
                ),
                'paramOne': F('session__startTime'),
                'paramTwo': ExpressionWrapper(12 * F('year') + F('month'), output_field=IntegerField()),
            })
        elif rule == 'SessionAlphaFirst':
            annotations.update({
                'nullParam': Case(
                    When(session__name__isnull=False, then=0),
                    When(month__isnull=False, then=1),
                    default_value=2,
                    output_field=IntegerField()
                ),
                'paramOne': F('session__name'),
                'paramTwo': ExpressionWrapper(12 * F('year') + F('month'), output_field=IntegerField()),
            })
        elif rule == 'Month':
            annotations.update({
                'nullParam': Case(
                    When(month__isnull=False, then=0),
                    default_value=1,
                    output_field=IntegerField()
                ),
                'paramOne': ExpressionWrapper(12*F('year') + F('month'), output_field=IntegerField()),
            })
        elif rule == 'Session':
            annotations.update({
                'nullParam': Case(
                    When(session__startTime__isnull=False, then=0),
                    default_value=1,
                    output_field=IntegerField()
                ),
                'paramOne': F('session__startTime'),
            })
        elif rule == 'SessionAlpha':
            annotations.update({
                'nullParam': Case(
                    When(session__name__isnull=False, then=0),
                    default_value=1,
                    output_field=IntegerField()
                ),
                'paramOne': F('session__name'),
            })
        elif rule == 'SessionMonth':
            annotations.update({
                'nullParam': Case(
                    When(Q(session__startTime__isnull=False) & Q(month__isnull=False), then=0),
                    When(Q(session__startTime__isnull=True) & Q(month__isnull=False), then=1),
                    When(Q(session__startTime__isnull=False) & Q(month__isnull=True), then=2),
                    default_value=3,
                    output_field=IntegerField()
                ),
                'paramOne': ExpressionWrapper(12 * F('year') + F('month'), output_field=IntegerField()),
                'paramTwo': F('session__startTime'),
            })
        elif rule == 'SessionAlphaMonth':
            annotations.update({
                'nullParam': Case(
                    When(Q(session__name__isnull=False) & Q(month__isnull=False), then=0),
                    When(Q(session__name__isnull=True) & Q(month__isnull=False), then=1),
                    When(Q(session__name__isnull=False) & Q(month__isnull=True), then=2),
                    default_value=3,
                    output_field=IntegerField()
                ),
                'paramOne': ExpressionWrapper(12*F('year') + F('month'), output_field=IntegerField()),
                'paramTwo': F('session__name'),
            })
        elif rule == 'Weekday':
            annotations.update({
                'nullParam': Case(
                    When(startTime__week_day__isnull=False, then=0),
                    default_value=1,
                    output_field=IntegerField()
                ),
                'paramOne': ExtractWeekDay('startTime'),
            })
        elif rule == 'MonthWeekday':
            annotations.update({
                'nullParam': Case(
                    When(Q(month__isnull=False) & Q(startTime__week_day__isnull=False), then=0),
                    default_value=1,
                    output_field=IntegerField()
                ),
                'paramOne': ExpressionWrapper(12*F('year') + F('month'), output_field=IntegerField()),
                'paramTwo': ExtractWeekDay('startTime'),
            })

        return annotations
578397
def _validate_annotation(self, annotation):
        ''''''
        required_keys = set(self._required_keys)
        keys = set(key for key, val in annotation.items() if val)
        missing_keys = required_keys.difference(keys)
        if missing_keys:
            error = 'Annotation missing required fields: {0}'.format(
                missing_keys)
            raise AnnotationError(error)