Representation data; Representation metadata = null; String entityId = ModelUtils.getAboutRepresentation(rep); if(entityId != null){ data = entityhubYard.getRepresentation(entityId);
/** * Checks if the parsed Entity can be wrapped as a locally managed entity. * This checks currently of a {@link ManagedEntityState} is defined by the * metadata. * @param entity the entity to check * @return the state */ public static boolean canWrap(Entity entity) { //check the metadata for //if the entity is managed locally //if the entity has an state Reference stateUri = entity.getMetadata().getFirstReference(STATE); if(stateUri == null || !ManagedEntityState.isState(stateUri.getReference())){ return false; } //check the about String entityId = ModelUtils.getAboutRepresentation(entity.getMetadata()); if(entityId == null || !entityId.equals(entity.getRepresentation().getId())){ return false; } return true; } /**
/** * Checks if the parsed Entity can be wrapped as a locally managed entity. * This checks currently of a {@link ManagedEntityState} is defined by the * metadata. * @param entity the entity to check * @return the state */ public static boolean canWrap(Entity entity) { //check the metadata for //if the entity is managed locally //if the entity has an state Reference stateUri = entity.getMetadata().getFirstReference(STATE); if(stateUri == null || !ManagedEntityState.isState(stateUri.getReference())){ return false; } //check the about String entityId = ModelUtils.getAboutRepresentation(entity.getMetadata()); if(entityId == null || !entityId.equals(entity.getRepresentation().getId())){ return false; } return true; } /**
Representation data; Representation metadata = null; String entityId = ModelUtils.getAboutRepresentation(rep); if(entityId != null){ data = entityhubYard.getRepresentation(entityId);
/** * Sets the parsed default state to the metadata if no other one is already * present and that wraps the entity as locally managed entity. * @param entity the entity * @param defaultState the default state used if no one is yet defined for * this entity * @return the wrapped entity */ public static ManagedEntity init(Entity entity, ManagedEntityState defaultState){ Reference stateUri = entity.getMetadata().getFirstReference(STATE); if(stateUri == null || !ManagedEntityState.isState(stateUri.getReference())){ entity.getMetadata().setReference(STATE, defaultState.getUri()); } String entityId = ModelUtils.getAboutRepresentation(entity.getMetadata()); if(entityId == null){ entity.getMetadata().setReference( RdfResourceEnum.aboutRepresentation.getUri(), entity.getRepresentation().getId()); } else if(!entityId.equals(entity.getRepresentation().getId())){ //the metadata are about a different Entity -> throw new IllegalArgumentException(String.format( "The Metadata of the parsed Entity are not about the Entity ("+ "entity: %s | metadataId: %s | metadataAbout: %s)", entity.getRepresentation().getId(),entity.getMetadata().getId(), entityId)); }//else the ID value is OK return new ManagedEntity(entity,false); }
/** * Sets the parsed default state to the metadata if no other one is already * present and that wraps the entity as locally managed entity. * @param entity the entity * @param defaultState the default state used if no one is yet defined for * this entity * @return the wrapped entity */ public static ManagedEntity init(Entity entity, ManagedEntityState defaultState){ Reference stateUri = entity.getMetadata().getFirstReference(STATE); if(stateUri == null || !ManagedEntityState.isState(stateUri.getReference())){ entity.getMetadata().setReference(STATE, defaultState.getUri()); } String entityId = ModelUtils.getAboutRepresentation(entity.getMetadata()); if(entityId == null){ entity.getMetadata().setReference( RdfResourceEnum.aboutRepresentation.getUri(), entity.getRepresentation().getId()); } else if(!entityId.equals(entity.getRepresentation().getId())){ //the metadata are about a different Entity -> throw new IllegalArgumentException(String.format( "The Metadata of the parsed Entity are not about the Entity ("+ "entity: %s | metadataId: %s | metadataAbout: %s)", entity.getRepresentation().getId(),entity.getMetadata().getId(), entityId)); }//else the ID value is OK return new ManagedEntity(entity,false); }