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){
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){
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{
public static String[] serialiseFieldMapper(FieldMapper mapper){ if(mapper == null){ return null; } else { Collection<FieldMapping> mappings = mapper.getMappings(); String[] mappingStrings = new String[mappings.size()]; int index=0; for(Iterator<FieldMapping> it = mappings.iterator();it.hasNext();index++){ mappingStrings[index] = serialiseFieldMapping(it.next()); } return mappingStrings; } }
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{
public static String[] serialiseFieldMapper(FieldMapper mapper){ if(mapper == null){ return null; } else { Collection<FieldMapping> mappings = mapper.getMappings(); String[] mappingStrings = new String[mappings.size()]; int index=0; for(Iterator<FieldMapping> it = mappings.iterator();it.hasNext();index++){ mappingStrings[index] = serialiseFieldMapping(it.next()); } return mappingStrings; } }
/** * Serialises all {@link FieldMapping}s of the parsed {@link FieldMapper} * and stores them in the {@value Cache#FIELD_MAPPING_CONFIG_FIELD} of the * parsed {@link Representation} * @param config the representation to store the field mapping configuration * @param mapper the field mapper with the configuration to store */ private static void writeFieldConfig(Representation config, FieldMapper mapper){ StringBuilder builder = new StringBuilder(); for(FieldMapping mapping : mapper.getMappings()){ builder.append(FieldMappingUtils.serialiseFieldMapping(mapping)); builder.append('\n'); } config.set(Cache.FIELD_MAPPING_CONFIG_FIELD, builder.toString()); } }
/** * Serialises all {@link FieldMapping}s of the parsed {@link FieldMapper} * and stores them in the {@value Cache#FIELD_MAPPING_CONFIG_FIELD} of the * parsed {@link Representation} * @param config the representation to store the field mapping configuration * @param mapper the field mapper with the configuration to store */ private static void writeFieldConfig(Representation config, FieldMapper mapper){ StringBuilder builder = new StringBuilder(); for(FieldMapping mapping : mapper.getMappings()){ builder.append(FieldMappingUtils.serialiseFieldMapping(mapping)); builder.append('\n'); } config.set(Cache.FIELD_MAPPING_CONFIG_FIELD, builder.toString()); } }
if (configuredMappings.getMappings().isEmpty()) {
if (configuredMappings.getMappings().isEmpty()) {
FieldMapper siteMapper = site.getFieldMapper(); FieldMapper mapper = this.fieldMapper.clone(); for(FieldMapping siteMapping : siteMapper.getMappings()){ mapper.addMapping(siteMapping);
FieldMapper siteMapper = site.getFieldMapper(); FieldMapper mapper = this.fieldMapper.clone(); for(FieldMapping siteMapping : siteMapper.getMappings()){ mapper.addMapping(siteMapping);