Package org.apache.stanbol.entityhub.servicesapi.mapping

Examples of org.apache.stanbol.entityhub.servicesapi.mapping.FieldMapping

Note that a Filter with the pattern '*' no constraint and only an null value as mapping would create a 1:1 copy of the source. TODO: Is it OK to keep an actual implementation in the Service API package? @author Rupert Westenthaler

            String mappingString = mappings.next();
            log.debug(mappingString);
            if(mappingString != null &&
                    !mappingString.isEmpty() && //not an empty line
                    !(mappingString.charAt(0) == FieldMapping.COMMENT_CHAR)){ //not an comment
                FieldMapping fieldMapping = parseFieldMapping(mappingString.toString(),nps);
                if(fieldMapping != null){
                    fieldMappings.add(fieldMapping);
                } else {
                    log.warn("Unable to parse FieldMapping for '{}'",mappingString);
                }
View Full Code Here


        // init the fieldMapper based on the configuration
        FieldMapper fieldMappings = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance());
        if (siteConfiguration.getFieldMappings() != null) {
            log.debug(" > Initialise configured field mappings");
            for (String configuredMapping : siteConfiguration.getFieldMappings()) {
                FieldMapping mapping =
                        FieldMappingUtils.parseFieldMapping(configuredMapping, nsPrefixService);
                if (mapping != null) {
                    log.debug("   - add FieldMapping {}", mapping);
                    fieldMappings.addMapping(mapping);
                }
View Full Code Here

    private static FieldMapper readFieldConfig(Yard yard,Representation config, NamespacePrefixService nsPrefixService) {
        Object mappingValue = config.getFirst(Cache.FIELD_MAPPING_CONFIG_FIELD);
        if(mappingValue != null){
            DefaultFieldMapperImpl fieldMapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance());
            for(String mappingStirng : mappingValue.toString().split("\n")){
                FieldMapping mapping = FieldMappingUtils.parseFieldMapping(mappingStirng, nsPrefixService);
                if(mapping != null){
                    log.info("  > add Mapping: "+mappingStirng);
                    fieldMapper.addMapping(mapping);
                }
            }
View Full Code Here

        //    can use the valueFactory of the configured Yard to create instances
        //    of converted values!
        log.info(" ... init FieldMappings");
        fieldMapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance());
        for(String mappingString : config.getFieldMappingConfig()){
            FieldMapping mapping = FieldMappingUtils.parseFieldMapping(mappingString);
            if(mapping != null){
                log.info("   + mapping: "+mapping);
                fieldMapper.addMapping(mapping);
            }
        }
View Full Code Here

                 *   be always the last.
                 *   So we need to parse backwards because than more prominent
                 *   things will overwrite and win!
                 */
                for(int i=activeMappings.size()-1;i>=0;i--){
                    FieldMapping mapping = activeMappings.get(i);
                    if(mapping.usesWildcard() //if wildcard
                            && !mapping.ignoreField() && //and not ignore
                            mapping.getFilter() != null && //and a filter is present
                            mapping.getFilter().getType() == ConstraintType.text){ //and of type text
                        //set the global text filter.
                        //NOTE: the active mappings are sorted in that way, that
                        //      the most specific one is set last
                        globalFilter = (TextConstraint)mapping.getFilter();
                    }
                    for(String targetField : mapping.getMappings()){
                        if(mapping.ignoreField()){
                            targetFields.remove(targetField);
                        } else {
                            targetFields.add(targetField);
                        }
                    }
                }
//                log.info("    o targets: "+targetFields);
//                log.info("    o global text filter: "+globalFilter);
                if(globalFilter != null){
                    globalFiltered = new HashSet<Object>(values);
                    //parse false ass third argument, because we need not to filter
                    //non-Text values for wildcard filter!
                    processFilter(globalFilter, globalFiltered,false);
                }
                //now process the mappings
                for(FieldMapping mapping : activeMappings){
                    if(!mapping.ignoreField() &&
                            !Collections.disjoint(targetFields, mapping.getMappings())){
                        processMapping(mapping, valueFactory, field,  values,globalFiltered, targetFields, target);
//                    } else if(!mapping.ignoreField()) {
//                        log.info(String.format("  << ignore mapping %s ",mapping));
//                    } else {
//                        log.info(String.format("  << %s ",mapping));
View Full Code Here

        Object mappings = context.getProperties().get(Cache.ADDITIONAL_MAPPINGS);
        FieldMapper configuredMappings = null;
        if (mappings instanceof String[] && ((String[]) mappings).length > 0) {
            configuredMappings = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance());
            for (String mappingString : (String[]) mappings) {
                FieldMapping fieldMapping = FieldMappingUtils.parseFieldMapping(mappingString);
                if (fieldMapping != null) {
                    configuredMappings.addMapping(fieldMapping);
                }
            }
            //check if there are valid mappings
View Full Code Here

    private static FieldMapper readFieldConfig(Yard yard,Representation config) {
        Object mappingValue = config.getFirst(Cache.FIELD_MAPPING_CONFIG_FIELD);
        if(mappingValue != null){
            DefaultFieldMapperImpl fieldMapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance());
            for(String mappingStirng : mappingValue.toString().split("\n")){
                FieldMapping mapping = FieldMappingUtils.parseFieldMapping(mappingStirng);
                if(mapping != null){
                    log.info("  > add Mapping: "+mappingStirng);
                    fieldMapper.addMapping(mapping);
                }
            }
View Full Code Here

        if(ignore && filter != null){
            log.warn("Filters are not supported for '!<fieldPatter>' type field mappings! Filter {} ignored",filter);
            filter = null;
        }
        try {
            return new FieldMapping(fieldPattern, filter, mappedTo.toArray(new String[mappedTo.size()]));
        }catch (RuntimeException e) {
            log.warn(String.format("Unable to parse FieldMapping from Line '%s'",
                mapping),e);
            return null;
        }
View Full Code Here

            String mappingString = mappings.next();
            log.debug(mappingString);
            if(mappingString != null &&
                    !mappingString.isEmpty() && //not an empty line
                    !(mappingString.charAt(0) == FieldMapping.COMMENT_CHAR)){ //not an comment
                FieldMapping fieldMapping = FieldMappingUtils.parseFieldMapping(mappingString.toString());
                if(fieldMapping != null){
                    fieldMappings.add(fieldMapping);
                } else {
                    log.warn("Unable to parse FieldMapping for '{}'",mappingString);
                }
View Full Code Here

        //init the fieldMapper based on the configuration
        fieldMappings = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance());
        if(siteConfiguration.getFieldMappings() != null){
            log.debug(" > Initialise configured field mappings");
            for(String configuredMapping : siteConfiguration.getFieldMappings()){
                FieldMapping mapping = FieldMappingUtils.parseFieldMapping(configuredMapping);
                if(mapping != null){
                    log.debug("   - add FieldMapping {}",mapping);
                    fieldMappings.addMapping(mapping);
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.entityhub.servicesapi.mapping.FieldMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.