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

Examples of org.apache.stanbol.entityhub.servicesapi.model.Representation.addReference()


            NodeTransformer fieldTransformer = program.getField(entry.getKey()).getTransformer();
            if(fieldTransformer == null || fieldTransformer instanceof IdentityTransformer<?>){
                //we need to convert the RDFBackend Node to an Representation object
                for(Object value : entry.getValue()){
                    if(backend.isURI(value)){
                        result.addReference(entry.getKey(), backend.stringValue(value));
                    } else if(backend.isLiteral(value)){ //literal
                        Locale locale = backend.getLiteralLanguage(value);
                        if(locale != null){ //text with language
                            String lang = locale.getLanguage();
                            result.addNaturalText(entry.getKey(), backend.stringValue(value),
View Full Code Here


    public void testStoreToContextEnabledYard() throws YardException{
        //add a new entity to yard 2
        String context2added = "http://www.test.org/addedEntity";
        Representation rep = RdfValueFactory.getInstance().createRepresentation(
            context2added);
        rep.addReference(rdfType.stringValue(), skosConcept.stringValue());
        rep.addNaturalText(skosPrefLabel.stringValue(), "added Entity", "en");
        rep.addNaturalText(skosPrefLabel.stringValue(), "hinzugefüte Entity", "de");
        yard2.store(rep);
        //test visibility to other yards
        Assert.assertFalse(yard1.isRepresentation(context2added));
View Full Code Here

        String field = "urn:the.field:used.for.this.Test";
        Set<String> refs = new HashSet<String>(Arrays.asList("http://www.test.org/test1",
            "urn:test.org:test.1"));
        Representation rep = createRepresentation(null);
        for (String ref : refs) {
            rep.addReference(field, ref);
        }
        Iterator<Reference> refIterator = rep.getReferences(field);
        assertNotNull(refIterator);
        while (refIterator.hasNext()) {
            Reference ref = refIterator.next();
View Full Code Here

    public void testRemoveAllNaturalLanguageValues() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        // add a reference to ensure that only texts (and strings) are removed
        String testReference = "http://www.test.org/test";
        rep.addReference(field, testReference);
        // test removal of all natural language values by parsing no languages
        rep.removeAllNaturalText(field);
        Iterator<Text> texts = rep.get(field, (String[]) null);
        assertFalse(texts.hasNext()); // not texts any more
        assertTrue(rep.get(field).hasNext()); // but still a reference!
View Full Code Here

    public void testRemoveAllNaturalLanguageValuesByParsingAnEmptyArray() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        // add a reference to ensure that only texts (and strings) are removed
        String testReference = "http://www.test.org/test";
        rep.addReference(field, testReference);
        // test removal of all natural language values by parsing an empty language array
        rep.removeAllNaturalText(field, new String[] {});
        Iterator<Text> texts = rep.get(field, (String[]) null);
        assertFalse(texts.hasNext());
        assertTrue(rep.get(field).hasNext()); // text of the added reference is still present
View Full Code Here

    public void testRemoveAllNaturalLanguageValuesByParsingNullAsLanguageArray() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        // add a reference to ensure that only texts (and strings) are removed
        String testReference = "http://www.test.org/test";
        rep.addReference(field, testReference);
        // test removal of all natural language values by parsing only a single argument
        rep.removeAllNaturalText(field);
        Iterator<Text> texts = rep.get(field, (String[]) null);
        assertFalse(texts.hasNext());
        assertTrue(rep.get(field).hasNext()); // text of the added reference is still present
View Full Code Here

     */
    @Test(expected = IllegalArgumentException.class)
    public void testAddNullReference() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = createRepresentation(null);
        rep.addReference(field, null);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testAddNullText() {
        String field = "urn:the.field:used.for.this.Test";
View Full Code Here

        String testText = "This is a Test";
        Integer testValue = 42;
        Representation rep = createRepresentation(null);
        rep.add(field, testValue);
        rep.addNaturalText(field, testText, "en");
        rep.addReference(field, testReference);
        rep.set(field, null); // need to remove all values
        Iterator<Object> values = rep.get(field);
        assertNotNull(values);
        assertFalse(values.hasNext());
        // test specific setter (also specific setters need to remove all values)
View Full Code Here

        assertNotNull(values);
        assertFalse(values.hasNext());
        // test specific setter (also specific setters need to remove all values)
        rep.add(field, testValue);
        rep.addNaturalText(field, testText, "en");
        rep.addReference(field, testReference);
        rep.setNaturalText(field, null);
        assertNotNull(values);
        assertFalse(values.hasNext());

        rep.add(field, testValue);
View Full Code Here

        assertNotNull(values);
        assertFalse(values.hasNext());

        rep.add(field, testValue);
        rep.addNaturalText(field, testText, "en");
        rep.addReference(field, testReference);
        rep.setReference(field, null);
        assertNotNull(values);
        assertFalse(values.hasNext());
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.