use of org.apache.stanbol.entityhub.servicesapi.model.MappingState in project stanbol by apache.
the class EntityhubImpl method establishMapping.
/**
* Creates a new {@link EntityMapping} for the parsed source and target
* {@link Entity}. This also sets the State and the expire date based on the
* configurations of the ReferencesSite of the source entity and the defaults of the
* Entityhub
* @param localEntity the locally managed entity (target for the mapping)
* @param remoteEntity the remote Entity (source for the mapping)
* @param site the referenced site managing the source Entity
* @param entityMappingRepresentation the Entity for the mapping
* @return the EntityMapping
*/
private EntityMapping establishMapping(Entity localEntity, Entity remoteEntity, Site site, Entity entityMappingEntity) {
EntityMapping entityMapping = EntityMapping.init(entityMappingEntity);
//now init the mappingState and the expireDate based on the config of the
//ReferencedSite of the source entity (considering also the defaults of the entityhub)
SiteConfiguration siteConfig = site.getConfiguration();
MappingState mappingState = siteConfig.getDefaultMappedEntityState();
if (mappingState == null) {
mappingState = config.getDefaultMappingState();
}
entityMapping.setState(mappingState);
long expireDuration = siteConfig.getDefaultExpireDuration();
if (expireDuration > 0) {
Date expireDate = new Date(System.currentTimeMillis() + expireDuration);
entityMapping.setExpires(expireDate);
}
entityMapping.setSourceId(remoteEntity.getId());
entityMapping.setTargetId(localEntity.getId());
//initialise additional metadata
entityMapping.setCreated(new Date());
return entityMapping;
}
Aggregations