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

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


     * argument to this method.
     * @param mappings The mappings or <code>null</code> if none
     * @return A new and configured FieldMapper instance.
     */
    public static FieldMapper createDefaultFieldMapper(Iterator<String> mappings, NamespacePrefixService nps){
        FieldMapper mapper =  new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance());
        if(mappings != null){
            for(FieldMapping mapping : parseFieldMappings(mappings,nps)){
                mapper.addMapping(mapping);
            }
        }
        return mapper;
    }
View Full Code Here


     * 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;
    }
View Full Code Here

                && siteConfiguration.getEntityDereferencerType() != null
                && siteConfiguration.getEntityDereferencerType().equals(
                    siteConfiguration.getEntitySearcherType());

        // 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);
                }
            }
        }
        // now init the referenced Services
        initDereferencerAndEntitySearcher();
View Full Code Here

        if(yard == null){
            throw new IllegalArgumentException("The parsed Yard MUST NOT be NULL!");
        }
        Representation baseConfig = yard.getRepresentation(Cache.BASE_CONFIGURATION_URI);
        if(baseConfig != null){
            FieldMapper mapper = readFieldConfig(yard,baseConfig, nsPrefixService);
            if(mapper == null){
                String msg = "Invalid Base Configuration: Unable to parse FieldMappings from Field "+Cache.FIELD_MAPPING_CONFIG_FIELD;
                log.error(msg);
                if(log.isErrorEnabled()){
                    log.error(ModelUtils.getRepresentationInfo(baseConfig));
View Full Code Here

        if(yard == null){
            throw new IllegalArgumentException("The parsed Yard MUST NOT be NULL!");
        }
        Representation addConfig = yard.getRepresentation(Cache.ADDITIONAL_CONFIGURATION_URI);
        if(addConfig != null){
            FieldMapper mapper = readFieldConfig(yard,addConfig, nsPrefixService);
            if(mapper == null){
                log.warn("Invalid Additinal Configuration: Unable to parse FieldMappings from Field "+Cache.FIELD_MAPPING_CONFIG_FIELD+"-> return NULL (no additional Configuration)");
                if(log.isWarnEnabled()){
                    log.warn(ModelUtils.getRepresentationInfo(addConfig));
                }
View Full Code Here

        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());
View Full Code Here

        //(1) Read the base mappings from the Yard
        this.baseMapper = CacheUtils.loadBaseMappings(yard);

        //(2) Init the additional mappings based on the configuration
        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
            if (configuredMappings.getMappings().isEmpty()) {
                configuredMappings = null; //if no mappings where found set to null
            }
        }
        FieldMapper yardAdditionalMappings = CacheUtils.loadAdditionalMappings(yard);
        if (yardAdditionalMappings == null) {
            if (configuredMappings != null) {
                setAdditionalMappings(yard, configuredMappings);
            }
        } else if (!yardAdditionalMappings.equals(configuredMappings)) {
            //this may also set the additional mappings to null!
            log.info("Replace Additional Mappings for Cache " + yardId + "with Mappings configured by OSGI");
            setAdditionalMappings(yard, configuredMappings);
        } //else current config equals configured one -> nothing to do!
        initWithYard = true;
View Full Code Here

     * @param yard the yard used to set the configured additional mappings
     * @param fieldMapper the configuration
     * @throws YardException on any error while accessing the yard
     */
    protected void setAdditionalMappings(Yard yard, FieldMapper fieldMapper) throws YardException {
        FieldMapper old = this.additionalMapper;
        this.additionalMapper = fieldMapper;
        try {
            CacheUtils.storeAdditionalMappingsConfiguration(yard, additionalMapper);
        } catch (YardException e) {
            this.additionalMapper = old;
View Full Code Here

        Yard yard = getCacheYard();
        if (yard == null) {
            throw new YardException(String.format("The Yard %s for this cache is currently not available", yardId));
        } else {
            if (isAvailable()) {
                FieldMapper old = this.baseMapper;
                this.baseMapper = fieldMapper;
                try {
                    CacheUtils.storeBaseMappingsConfiguration(yard, baseMapper);
                } catch (YardException e) {
                    this.baseMapper = old;
View Full Code Here

        if(yard == null){
            throw new IllegalArgumentException("The parsed Yard MUST NOT be NULL!");
        }
        Representation baseConfig = yard.getRepresentation(Cache.BASE_CONFIGURATION_URI);
        if(baseConfig != null){
            FieldMapper mapper = readFieldConfig(yard,baseConfig);
            if(mapper == null){
                String msg = "Invalid Base Configuration: Unable to parse FieldMappings from Field "+Cache.FIELD_MAPPING_CONFIG_FIELD;
                log.error(msg);
                if(log.isErrorEnabled()){
                    log.error(ModelUtils.getRepresentationInfo(baseConfig));
View Full Code Here

TOP

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

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.