@Override public Representation process(Representation source) { if(mapper == null){ throw new IllegalStateException("The mapper is not initialised. One must call setConfiguration to configure the FieldMapper!"); } if(source == null){ return null; } else { return mapper.applyMappings(source, vf.createRepresentation(source.getId()), vf); } } /**
/** * Getter for the base mappings used by this Cache. Modifications on the * returned object do not have any influence on the mappings, because this * method returns a clone. Use {@link #setBaseMappings(FieldMapper)} to * change the used base mappings. However make sure you understand the * implications of changing the base mappings as described in the * documentation of the setter method * * @return A clone of the base mappings or <code>null</code> if no base * mappings are defined */ @Override public final FieldMapper getBaseMappings() { return baseMapper == null ? null : baseMapper.clone(); }
public FiledMapperProcessor(FieldMapper mapper, NamespacePrefixService nps, ValueFactory vf){ this(nps,vf); if(mapper == null){ throw new IllegalArgumentException("The parsed FieldMapper MUST NOT be NULL!"); } else if(mapper.getMappings().isEmpty()){ throw new IllegalStateException("The parsed field mappings MUST contain at least a single valid mapping!"); } this.mapper = mapper; } public FiledMapperProcessor(Iterator<String> mappings, NamespacePrefixService nps, ValueFactory vf){
FieldMapper mapper = this.fieldMapper.clone(); for(FieldMapping siteMapping : siteMapper.getMappings()){ mapper.addMapping(siteMapping); mapper.applyMappings(remoteEntity.getRepresentation(), localEntity.getRepresentation(),valueFactory);
/** * Creates an FieldMapper instance by using the {@link DefaultFieldMapperImpl} * and the default instance if the {@link ValueConverterFactory} and configure * it with {@link FieldMapping}s * @param mappings The mappings or <code>null</code> if none * @return A new and configured FieldMapper instance. */ public static FieldMapper createDefaultFieldMapper(Iterable<FieldMapping> mappings){ FieldMapper mapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance()); if(mappings != null){ for(FieldMapping mapping : mappings){ mapper.addMapping(mapping); } } return mapper; }
FieldMapping fieldMapping = FieldMappingUtils.parseFieldMapping(mappingString, nsPrefixService); if (fieldMapping != null) { configuredMappings.addMapping(fieldMapping); if (configuredMappings.getMappings().isEmpty()) {
fieldMapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance()); for(FieldMapping mapping : mappings){ fieldMapper.addMapping(mapping); fieldMapper = dereferencer.getFieldMapper().clone(); } else { fieldMapper = null; fieldMapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance()); fieldMapper.addMapping(new FieldMapping(new TextConstraint( (String)null, langs.toArray(new String[langs.size()]))));
FieldMapper mapper = this.fieldMapper.clone(); for(FieldMapping siteMapping : siteMapper.getMappings()){ mapper.addMapping(siteMapping); mapper.applyMappings(remoteEntity.getRepresentation(), localEntity.getRepresentation(),valueFactory);
/** * Creates an FieldMapper instance by using the {@link DefaultFieldMapperImpl} * and the default instance if the {@link ValueConverterFactory} and configure * it with {@link FieldMapping}s * @param mappings The mappings or <code>null</code> if none * @return A new and configured FieldMapper instance. */ public static FieldMapper createDefaultFieldMapper(Iterable<FieldMapping> mappings){ FieldMapper mapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance()); if(mappings != null){ for(FieldMapping mapping : mappings){ mapper.addMapping(mapping); } } return mapper; }
FieldMapping fieldMapping = FieldMappingUtils.parseFieldMapping(mappingString, nsPrefixService); if (fieldMapping != null) { configuredMappings.addMapping(fieldMapping); if (configuredMappings.getMappings().isEmpty()) {
fieldMapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance()); for(FieldMapping mapping : mappings){ fieldMapper.addMapping(mapping);
@Override public Representation process(Representation source) { if(mapper == null){ throw new IllegalStateException("The mapper is not initialised. One must call setConfiguration to configure the FieldMapper!"); } if(source == null){ return null; } else { return mapper.applyMappings(source, vf.createRepresentation(source.getId()), vf); } } /**
public FiledMapperProcessor(FieldMapper mapper, NamespacePrefixService nps, ValueFactory vf){ this(nps,vf); if(mapper == null){ throw new IllegalArgumentException("The parsed FieldMapper MUST NOT be NULL!"); } else if(mapper.getMappings().isEmpty()){ throw new IllegalStateException("The parsed field mappings MUST contain at least a single valid mapping!"); } this.mapper = mapper; } public FiledMapperProcessor(Iterator<String> mappings, NamespacePrefixService nps, ValueFactory vf){
/** * Getter for the base mappings used by this Cache. Modifications on the * returned object do not have any influence on the mappings, because this * method returns a clone. Use {@link #setBaseMappings(FieldMapper)} to * change the used base mappings. However make sure you understand the * implications of changing the base mappings as described in the * documentation of the setter method * * @return A clone of the base mappings or <code>null</code> if no base * mappings are defined */ @Override public final FieldMapper getBaseMappings() { return baseMapper == null ? null : baseMapper.clone(); }
public EntityhubImpl(Yard entityhubYard, SiteManager siteManager, EntityhubConfiguration config, NamespacePrefixService nsPrefixService) { if(entityhubYard == null){ throw new IllegalArgumentException("The parsed Yard MUST NOT be NULL!"); } this.entityhubYard = entityhubYard; if(siteManager == null){ throw new IllegalArgumentException("The parsed SiteManager MUST NOT be NULL!"); } this.siteManager = siteManager; if(config == null){ throw new IllegalArgumentException("The parsed EntityhubConfig MUST NOT be NULL!"); } this.config = config; log.info(" ... init FieldMappings"); fieldMapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance()); for(String mappingString : config.getFieldMappingConfig()){ FieldMapping mapping = FieldMappingUtils.parseFieldMapping(mappingString,nsPrefixService); if(mapping != null){ log.info(" + mapping: "+mapping); fieldMapper.addMapping(mapping); } } }
try { RdfRepresentation clerezzaRep = valueFactory.createRdfRepresentation(uri, graph); fieldMapper.applyMappings(rep, clerezzaRep, valueFactory); if(log.isTraceEnabled()){ log.trace("dereferenced via Mappings {}", ModelUtils.getRepresentationInfo(clerezzaRep));
public FiledMapperProcessor(Iterator<String> mappings, NamespacePrefixService nps, ValueFactory vf){ this(nps, vf); if(mappings == null){ throw new IllegalArgumentException("The parsed field mappings MUST NOT be NULL!"); } mapper = FieldMappingUtils.createDefaultFieldMapper(mappings,nsPrefixService); if(mapper.getMappings().isEmpty()){ throw new IllegalStateException("The parsed field mappings MUST contain at least a single valid mapping!"); } } public FiledMapperProcessor(InputStream mappings, NamespacePrefixService nps, ValueFactory vf) throws IOException{
/** * Getter for the additional mappings used by this Cache. Modifications on the * returned object do not have any influence on the mappings, because this * method returns a clone. Use {@link #setAdditionalMappings(FieldMapper)} to * change the used additional mappings. However make sure you understand the * implications of changing the base mappings as described in the * documentation of the setter method * * @return A clone of the additional mappings or <code>null</code> if no * additional mappings are defined */ @Override public final FieldMapper getAdditionalMappings() { return additionalMapper == null ? null : additionalMapper.clone(); }
public EntityhubImpl(Yard entityhubYard, SiteManager siteManager, EntityhubConfiguration config, NamespacePrefixService nsPrefixService) { if(entityhubYard == null){ throw new IllegalArgumentException("The parsed Yard MUST NOT be NULL!"); } this.entityhubYard = entityhubYard; if(siteManager == null){ throw new IllegalArgumentException("The parsed SiteManager MUST NOT be NULL!"); } this.siteManager = siteManager; if(config == null){ throw new IllegalArgumentException("The parsed EntityhubConfig MUST NOT be NULL!"); } this.config = config; log.info(" ... init FieldMappings"); fieldMapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance()); for(String mappingString : config.getFieldMappingConfig()){ FieldMapping mapping = FieldMappingUtils.parseFieldMapping(mappingString,nsPrefixService); if(mapping != null){ log.info(" + mapping: "+mapping); fieldMapper.addMapping(mapping); } } }
/** * Applies the mappings defined by the {@link #baseMapper} and the {@link #additionalMapper} * to the parsed Representation. * * @param yard The yard (local reference to avoid syncronization) * @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); } if (additionalMapper != null) { if (mapped == null) { mapped = yard.getValueFactory().createRepresentation(representation.getId()); } additionalMapper.applyMappings(representation, mapped,valueFactory); } log.info(" -- applied mappings in " + (System.currentTimeMillis() - start) + "ms"); return mapped != null ? mapped : representation; }