use of org.apache.stanbol.entityhub.servicesapi.model.ManagedEntityState in project stanbol by apache.
the class EntityhubImpl method importEntity.
/**
* Imports a {@link Entity} from a {@link Site}. This Method imports
* the {@link Representation} by applying all configured mappings. It also
* sets the {@link ManagedEntityState} to the configured default value by the
* referenced site of the imported entity or the default for the Entityhub
* if the site does not define this configuration.<p>
* @param remoteEntity The entity to import
* @param site the referenced site of the entity to import
* @param localEntity the target entity for the import
* @param valueFactory the valusFactory used to create instance while importing
*/
private void importEntity(Entity remoteEntity, Site site, Entity localEntity, ValueFactory valueFactory) {
SiteConfiguration siteConfig = site.getConfiguration();
ManagedEntityState state;
state = siteConfig.getDefaultManagedEntityState();
if (state == null) {
state = config.getDefaultManagedEntityState();
}
// this wrapper allows to use an API to write metadata
ManagedEntity managedEntity = ManagedEntity.init(localEntity, state);
FieldMapper siteMapper = site.getFieldMapper();
FieldMapper mapper = this.fieldMapper.clone();
for (FieldMapping siteMapping : siteMapper.getMappings()) {
mapper.addMapping(siteMapping);
}
// TODO: As soon as MappingActivities are implemented we need to add such
// information to the EntityMapping instance!
mapper.applyMappings(remoteEntity.getRepresentation(), localEntity.getRepresentation(), valueFactory);
// set general metadata
managedEntity.setCreated(new Date());
// set the metadata required by the referenced site
managedEntity.addAttributionLink(site.getConfiguration().getAttributionUrl());
managedEntity.addAttributionText(site.getConfiguration().getAttribution(), null);
// TODO: maybe replace with the URL of the site
managedEntity.addContributorName(site.getConfiguration().getName());
}
Aggregations