Package org.openbel.framework.common.model

Examples of org.openbel.framework.common.model.AnnotationDefinition


                    domainValues.add(value);
                    break;
                case URL:
                    //retrieve external resource
                    try {
                        AnnotationDefinition ad =
                                cacheableAnnotationDefinitionService
                                        .resolveAnnotationDefinition(value);
                        if (BELUtilities.hasItems(ad.getEnums())) {
                            //external enumerations
                            domainValues.addAll(ad.getEnums());
                        } else {
                            //pattern
                            domainValues.add(ad.getValue());
                        }
                    } catch (AnnotationDefinitionResolutionException e) {
                        throw new ExternalResourceException(e.getName(),
                                e.getMessage(), e);
                    }
View Full Code Here


        } catch (IndexingFailure e) {
            throw new AnnotationDefinitionResolutionException(resourceLocation,
                    e.getMessage());
        }

        AnnotationDefinition annotationDefinition = CommonModelFactory
                .getInstance().createAnnotationDefinition(annotationHeader.
                        getAnnotationBlock().getKeyword());
        annotationDefinition.setDescription(annotationHeader
                .getAnnotationBlock().getDescriptionString());
        annotationDefinition.setUsage(annotationHeader.getAnnotationBlock()
                .getUsageString());
        annotationDefinition.setType(annotationHeader.getAnnotationBlock()
                .getAnnotationType());
        annotationDefinition.setURL(resourceLocation);

        long characterOffset = annotationHeaderProcessor
                .getCharacterStopOffset();

        try {
            switch (annotationDefinition.getType()) {
            case ENUMERATION:
                annotationDefinition.setEnums(parseEnumData(
                        annotationCacheCopy,
                        annotationHeader.getProcessingBlock()
                                .getDelimiterString(),
                        characterOffset));
                break;
            case REGULAR_EXPRESSION:
                annotationDefinition.setValue(parseRegularExpression(
                        annotationCacheCopy, characterOffset));
            }
        } catch (IOException e) {
            throw new AnnotationDefinitionResolutionException(resourceLocation,
                    e.getMessage());
View Full Code Here

            if (annotations.containsKey(resourceLocation)) {
                return annotations.get(resourceLocation);
            }

            // resolve and parse
            AnnotationDefinition annotationDefinition =
                    cacheableAnnotationDefinitionService
                            .resolveAnnotationDefinition(resourceLocation);

            // cache annotation definition and return
            annotations.put(resourceLocation, annotationDefinition);
View Full Code Here

            // ignore it
        }
        // Pattern syntax is bad or annotation is not valid

        // The annotation is defined by its annotation definition.
        AnnotationDefinition annodef = annotation.getDefinition();

        String annodefID = annodef.getId();
        String url = annodef.getURL();
        String annoval = annotation.getValue();

        if (url == null) {
            throw new AnnotationSyntaxWarning(annodefID, annoval);
        }
View Full Code Here

     * Create a test {@link AnnotationGroup}.
     *
     * @return {@link AnnotationGroup}, the test annotation group
     */
    public AnnotationGroup createAnnotationGroup() {
        AnnotationDefinition speciesDefinition =
                new AnnotationDefinition("species", "Description", "Usage",
                        asList("9606"));
        AnnotationDefinition tissueDefinition =
                new AnnotationDefinition("tissue", "Description", "Usage",
                        asList("TH1", "TH2", "AB3"));

        AnnotationGroup annotationGroup = new AnnotationGroup();
        annotationGroup.setAnnotations(asList(
                CommonModelFactory.getInstance().createAnnotation("9606",
View Full Code Here

    public void testAnnotationResolution() {
        URL belannoUrl = getClass().getResource(
                "/org/openbel/framework/core/annotation/test.belanno");

        try {
            AnnotationDefinition anndef = annotationDefService
                    .resolveAnnotationDefinition(belannoUrl.toString());

            assertNotNull(anndef);
            assertNotNull(anndef.getEnums());
            assertFalse(anndef.getEnums().isEmpty());

            assertEquals("9606", anndef.getEnums().get(0));
            assertEquals("10090", anndef.getEnums().get(1));
            assertEquals("10116", anndef.getEnums().get(2));
        } catch (AnnotationDefinitionResolutionException e) {
            e.printStackTrace();
            fail(e.getUserFacingMessage());
        }
    }
View Full Code Here

        }

        String id = t.getId();
        String url = t.getUrl();

        AnnotationDefinition dest = CommonModelFactory.getInstance()
                .createAnnotationDefinition(id);
        dest.setURL(url);

        return dest;
    }
View Full Code Here

        if (ba == null) {
            return null;
        }

        List<Annotation> annotations = new ArrayList<Annotation>();
        AnnotationDefinition ad =
                adefs.get(ba.getAnnotationDefinition().getName());

        for (String value : ba.getValues()) {
            annotations.add(CommonModelFactory.getInstance().createAnnotation(
                    value, ad));
View Full Code Here

        if (a == null) {
            return null;
        }

        List<String> values = new ArrayList<String>();
        AnnotationDefinition ad = null;
        for (int i = 0; i < a.size(); i++) {
            Annotation ann = a.get(i);
            if (i == 0) {
                ad = ann.getDefinition();
            } else if (ad != null && !ad.equals(ann.getDefinition())) {
                throw new IllegalStateException(
                        "annotations must have equal definitions.");
            }

            values.add(ann.getValue());
View Full Code Here

    public AnnotationDefinition convert(BELAnnotationDefinition bad) {
        if (bad == null) {
            return null;
        }

        AnnotationDefinition ad = CommonModelFactory.getInstance()
                .createAnnotationDefinition(bad.getName());
        switch (bad.getAnnotationType()) {
        case LIST:
            ad.setType(AnnotationType.ENUMERATION);
            ad.setEnums(bad.getList());
            break;
        case PATTERN:
            ad.setType(AnnotationType.REGULAR_EXPRESSION);
            ad.setValue(bad.getValue());
            break;
        case URL:
            ad.setType(null);
            ad.setURL(bad.getValue());
            break;
        default:
            throw new InvalidArgument("BELAnnotationType '"
                    + bad.getAnnotationType() + "' not known.");
        }
View Full Code Here

TOP

Related Classes of org.openbel.framework.common.model.AnnotationDefinition

Copyright © 2018 www.massapicom. 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.