Package org.apache.stanbol.entityhub.servicesapi.model

Examples of org.apache.stanbol.entityhub.servicesapi.model.Reference


    }

    @Test
    public void testUriReference() throws URISyntaxException {
        URI refObject = new URI("http://www.test.org/uriTest");
        Reference ref = testRef(refObject);
        assertEquals(ref.getReference(), refObject.toString());
    }
View Full Code Here


    }

    @Test
    public void testURLReference() throws MalformedURLException {
        URL refObject = new URL("http://www.test.org/urlTest");
        Reference ref = testRef(refObject);
        assertEquals(ref.getReference(), refObject.toString());
    }
View Full Code Here

     *            the object representing the reference
     * @return the created {@link Reference} that can be used to perform further tests.
     */
    private Reference testRef(Object refObject) {
        ValueFactory vf = getValueFactory();
        Reference ref = vf.createReference(refObject);
        // check not null
        assertNotNull(ref);
        // check reference is not null
        assertNotNull(ref.getReference());
        return ref;
    }
View Full Code Here

        if(siteId == null || siteId.isEmpty()){
            throw new IllegalStateException("Parsed SiteId MUST NOT be NULL nor empty!");
        }
        this.site = siteId;
        this.representation = representation;
        Reference representationRef;
        if(metadata != null){
            if(representation.getId().equals(metadata.getId())){
                throw new IllegalArgumentException("The ID of the Representation and " +
                "the Metadata MUST NOT BE the same!");
            }
            representationRef = metadata.getFirstReference(
                RdfResourceEnum.aboutRepresentation.getUri());
            if(representationRef != null && !representationRef.getReference().equals(
                representation.getId())){
                throw new IllegalArgumentException(String.format(
                    "The parsed Metadata are not about the representation of the" +
                    "Entity to be created (metadata aboutness=%s, representation=%s).",
                    representationRef.getReference(),representation.getId()));
            }
            this.metadata = metadata;
        } else { //init new metadata
            //This is typically used if no metadata are persisted for an entity
            //(e.g. for entities of a remote site).
View Full Code Here

        if(metadata == null){
            return null;
        }
        Iterator<Reference> refs = metadata.getReferences(RdfResourceEnum.aboutRepresentation.getUri());
        if(refs.hasNext()){
            Reference about = refs.next();
            if(refs.hasNext()){
                log.warn("The parsed Representation {} claims to be the metadata of" +
                    "multiple Entities (entities: {})",
                    metadata.getId(),
                    asCollection(metadata.getReferences(RdfResourceEnum.aboutRepresentation.getUri())));
            }
            return about.getReference();
        } else {
            return null;
        }
    }
View Full Code Here

        rep.addReference(field, strRef);
        assertTrue(asCollection(rep.getFieldNames()).contains(field));
        rep.removeReference(field, strRef);
        assertFalse(asCollection(rep.getFieldNames()).contains(field));

        Reference ref = vf.createReference("urn:testValue2");
        rep.add(field, ref);
        assertTrue(asCollection(rep.getFieldNames()).contains(field));
        rep.remove(field, ref);
        assertFalse(asCollection(rep.getFieldNames()).contains(field));
View Full Code Here

    @Test
    public void testMultipleAddAndRemove() throws MalformedURLException, URISyntaxException {
        String field = "urn:the.field:used.for.this.Test";
        ValueFactory vf = getValueFactory();
        Representation rep = createRepresentation(null);
        Reference ref = vf.createReference("http://www.test.org/test");
        Text text = vf.createText("test", "en");
        Integer i = 42;
        Double d = Math.PI;
        URI uri = new URI("http://www.test.org/uriTest");
        URL url = new URL("http://www.test.org/urlTest");
View Full Code Here

            rep.addReference(field, ref);
        }
        Iterator<Reference> refIterator = rep.getReferences(field);
        assertNotNull(refIterator);
        while (refIterator.hasNext()) {
            Reference ref = refIterator.next();
            assertTrue(refs.remove(ref.getReference()));
        }
        assertTrue(refs.isEmpty());
    }
View Full Code Here

    /**
     * The state of this mapping
     * @return the state
     */
    public final MappingState getState() {
        Reference stateUri = wrappedEntity.getRepresentation().getFirstReference(STATE);
        if(stateUri != null){
            if(MappingState.isState(stateUri.getReference())){
                return MappingState.getState(stateUri.getReference());
            } else {
                log.warn("Value {} for field {} is not a valied MappingState! -> return null",
                    stateUri,STATE);
                return null;
            }
View Full Code Here

     * Getter for the ID of the Entity (and the Representation) this metadata
     * are about
     * @return the id of the entity this metadata are about
     */
    public final String getEntityId(){
        Reference ref = wrappedEntity.getRepresentation().getFirstReference(
            RdfResourceEnum.aboutRepresentation.getUri());
        return ref == null ? null : ref.getReference();
    }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.entityhub.servicesapi.model.Reference

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.