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

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


     * @param representation The representation to map
     * @return the mapped representation
     */
    private Representation applyCacheMappings(Yard yard, Representation representation) {
        long start = System.currentTimeMillis();
        Representation mapped = null;
        ValueFactory valueFactory = getValueFactory();
        if (baseMapper != null) {
            mapped = yard.getValueFactory().createRepresentation(representation.getId());
            baseMapper.applyMappings(representation, mapped,valueFactory);
        }
View Full Code Here


        if (yard == null) {
            throw new YardException(String.format("The Yard %s for this cache is currently not available", yardId));
        } else {
            //ensure that the baseConfig (if present) is not deleted by this
            //operation
            Representation baseConfig = yard.getRepresentation(Cache.BASE_CONFIGURATION_URI);
            yard.removeAll();
            if(baseConfig != null){
                yard.store(baseConfig);
            }
        }
View Full Code Here

    public void testIsRepresentation() throws YardException {
        String id = "urn:yard.test.testIsRepresentation:representation.id";
        Yard yard = getYard();
        // Representations created via the yard need to be created (as empty
        // representation within the yard
        Representation test = create();
        assertTrue(yard.isRepresentation(test.getId()));
        // Representations created via the ValueFactory MUST NOT be added to the
        // Yard
        Representation test2 = create(id, false);
        assertFalse(yard.isRepresentation(test2.getId()));
        // now store test2 and test again
        yard.store(test2);
        assertTrue(yard.isRepresentation(test2.getId()));
        // now remove test and test again
        yard.remove(test.getId());
        assertFalse(yard.isRepresentation(test.getId()));
        yard.remove(test2.getId());
        assertFalse(yard.isRepresentation(test2.getId()));
    }
View Full Code Here

    }

    @Test(expected = IllegalArgumentException.class)
    public void testUpdateRepresentationWithNonPresent() throws YardException {
        String id = "urn:yard.test.testUpdateRepresentationWithNonPresent:representation.id";
        Representation test = create(id, false);
        getYard().update(test); // throws an Exception because test is not part of the yard
    }
View Full Code Here

        // stored, but only that the update method works correctly
        Yard yard = getYard();
        String id1 = "urn:yard.test.testUpdateRepresentations:representation.id1";
        String id2 = "urn:yard.test.testUpdateRepresentations:representation.id2";
        String field = "urn:the.field:used.for.this.Test";
        Representation test1 = create(id1, true);
        Representation test2 = create(id2, true);
        // change the representations to be sure to force an update even if the
        // implementation checks for changes before updating a representation
        test1.add(field, "test value 1");
        test2.add(field, "test value 2");
        Iterable<Representation> updatedIterable = yard.update(Arrays.asList(test1, test2));
        assertNotNull(updatedIterable);
        Collection<Representation> updated = asCollection(updatedIterable.iterator());
        // test that both the parsed Representations where stored (updated & created)
        assertTrue(updated.remove(test1));
View Full Code Here

        // NOTE: this does not test if the updated view of the representation is
        // stored, but only that the update method works correctly
        Yard yard = getYard();
        String id1 = "urn:yard.test.testUpdateRepresentationsWithNullElement:representation.id";
        String field = "urn:the.field:used.for.this.Test";
        Representation test1 = create(id1, true);
        // change the representations to be sure to force an update even if the
        // implementation checks for changes before updating a representation
        test1.add(field, "test value 1");
        Iterable<Representation> updated = yard.update(Arrays.asList(test1, null));
        assertNotNull(updated);
        Iterator<Representation> updatedIt = updated.iterator();
        assertTrue(updatedIt.hasNext());
        assertEquals(test1, updatedIt.next());
View Full Code Here

            return null;
        }
        Yard entityhubYard = lookupYard();
        ValueFactory valueFactory = entityhubYard.getValueFactory();
        //Create the locally managed Entity
        Representation localRep = entityhubYard.create(constructResourceId(DEFAULT_MANAGED_ENTITY_PREFIX));
        Entity localEntity = loadEntity(entityhubYard, localRep);
        importEntity(remoteEntity, site, localEntity, valueFactory);

        //Second create and init the Mapping
        Representation entityMappingRepresentation = entityhubYard.create(
            constructResourceId(DEFAULT_MAPPING_PREFIX));
        Entity entityMappingEntity = loadEntity(entityhubYard, entityMappingRepresentation);
        establishMapping(localEntity, remoteEntity, site, entityMappingEntity);
       
        //Store the entity and the mappedEntity in the entityhubYard
View Full Code Here

        // stored, but only that the update method works correctly
        Yard yard = getYard();
        String id1 = "urn:yard.test.testUpdateRepresentationsWithNonPresent:representation.id1";
        String id2 = "urn:yard.test.testUpdateRepresentationsWithNonPresent:representation.id2";
        String field = "urn:the.field:used.for.this.Test";
        Representation test1 = create(id1, true);
        // change the representations to be sure to force an update even if the
        // implementation checks for changes before updating a representation
        test1.add(field, "test value 1");
        // create a 2nd Representation by using the ValueFactory (will not add it
        // to the yard!)
        Representation test2 = create(id2, false);
        // now test1 is present and test2 is not.
        Iterable<Representation> updated = yard.update(Arrays.asList(test1, test2));
        // We expect that only test1 is updated and test2 is ignored
        assertNotNull(updated);
        Iterator<Representation> updatedIt = updated.iterator();
View Full Code Here

     * thread has deleted that Entity in the meantime)
     * @throws YardException On any error with the parsed Yard.
     */
    private Entity loadEntity(Yard entityhubYard, Representation rep) throws YardException {
        if(rep != null){
            Representation data;
            Representation metadata = null;
            String entityId = ModelUtils.getAboutRepresentation(rep);
            if(entityId != null){
                data = entityhubYard.getRepresentation(entityId);
                metadata = rep;
            } else {
View Full Code Here

     * @return the metadata for that Entity or <code>null</code> if not existing
     * and <code>init == false</code>
     * @throws YardException
     */
    private Representation lookupMetadata(Yard entityhubYard, String entityId, boolean init) throws YardException {
        Representation metadata;
        //TODO: check the asumption that the Metadata always use the
        //      extension ".meta"
        String metaID = entityId+".meta";
        metadata = entityhubYard.getRepresentation(metaID);
        if(metadata == null){
View Full Code Here

TOP

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

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.