Examples of Mapping


Examples of org.apache.sling.serviceusermapping.impl.Mapping

            spec.append(':').append(subServiceName);
        }
        spec.append('=').append(userName);

        // spec analysis
        final Mapping mapping = new Mapping(spec.toString());
        TestCase.assertEquals(getField(mapping, "serviceName"), serviceName);
        TestCase.assertEquals(getField(mapping, "subServiceName"), subServiceName);
        TestCase.assertEquals(getField(mapping, "userName"), userName);

        // mapping
        TestCase.assertEquals(userName, mapping.map(serviceName, subServiceName));
        if (subServiceName == null) {
            // Mapping without subServiceName must not match request with any
            // subServiceName
            TestCase.assertNull(mapping.map(serviceName, subServiceName + "-garbage"));
        } else {
            // Mapping with subServiceName must not match request without
            // subServiceName
            TestCase.assertNull(mapping.map(serviceName, null));
        }

        // no match for different service name
        TestCase.assertNull(mapping.map(serviceName + "-garbage", subServiceName));

        // no match for null service name
        TestCase.assertNull(mapping.map(null, subServiceName));
    }
View Full Code Here

Examples of org.apache.sling.serviceusermapping.impl.Mapping

public class MappingTest {

    @Test
    public void test_constructor_null() {
        try {
            new Mapping(null);
            TestCase.fail("NullPointerException expected");
        } catch (NullPointerException npe) {
            // expected
        }
    }
View Full Code Here

Examples of org.apache.sling.serviceusermapping.impl.Mapping

    }

    @Test
    public void test_constructor_empty() {
        try {
            new Mapping("");
            TestCase.fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException iae) {
            // expected
        }
    }
View Full Code Here

Examples of org.apache.sling.serviceusermapping.impl.Mapping

    }

    @Test
    public void test_constructor_missing_user_name() {
        try {
            new Mapping("serviceName");
            TestCase.fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException iae) {
            // expected
        }

        try {
            new Mapping("serviceName=");
            TestCase.fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException iae) {
            // expected
        }
    }
View Full Code Here

Examples of org.apache.sling.serviceusermapping.impl.Mapping

    }

    @Test
    public void test_constructor_missing_service_name() {
        try {
            new Mapping("=user");
            TestCase.fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException iae) {
            // expected
        }
    }
View Full Code Here

Examples of org.apache.stanbol.entityhub.indexing.source.vcard.OntologyMappings.Mapping

        Representation rep = vf .createRepresentation(
            id);
        Map<String,Representation> representations = new HashMap<String,Representation>();
        representations.put(rep.getId(), rep);
        //add the type
        Mapping typeMapping = mappings.get(
            entityType == EntityType.person ? VCARD_PERSON : VCARD_ORGANIZATION);
        if(typeMapping != null){
            rep.add(NamespaceEnum.rdf+"type", typeMapping.uri);
        }
        log.debug("vCard [type: {} | name: '{}' | id: '{}']",
            new Object[]{entityType,name,rep.getId()});
        for(Property property : vCard.getProperties()){
            Property.Id propertyId = property.getId();
            String propName = propertyId.getPropertyName();
            if(mappings.containsKey(propName)){ //there is a mapping for this property
              //the Representation to write the Information of the current Property
                Representation current;
                //the Map with the mappings to be used for processing the current
                //Property
                Map<String,Mapping> currentMappings;
                Mapping mapping = mappings.get(propName); //May be null!!
                if(mapping == null || mapping.subMappings == null){
                    current = rep; //add to the base Representation
                    currentMappings = mappings; //and use the parsed mappings
                } else {
                    current = null; //indicates we need to create a new Representation
                    currentMappings = mapping.subMappings; //and use the sub mappings
                }
                switch (propertyId) {
                    case N:
                        N n = (N)property;
                        String given = n.getGivenName();
                        String family = n.getFamilyName();
                        if((given == null || given.isEmpty()) && (family == null
                                || family.isEmpty())){
                            log.warn("'N' property '{}'does not define given nor family name -> ignored",
                                n.getValue());
                        } else {
                            if(current == null){ //create new Representation
                                current = createSubRepresentation(rep, ".name",
                                    representations.keySet(), mapping);
                                representations.put(current.getId(), current);
                            }
                            Mapping subPropertyMapping = currentMappings.get(N_GIVEN);
                            if(subPropertyMapping != null && given != null && !given.isEmpty()){
                                current.addNaturalText(subPropertyMapping.uri, StringUtils.chomp(given).trim());
                            }
                            subPropertyMapping = currentMappings.get(N_FAMILY);
                            if(subPropertyMapping != null & family != null && !family.isEmpty()){
                                current.addNaturalText(subPropertyMapping.uri, StringUtils.chomp(family).trim());
                            }
                            String[] additional = n.getAdditionalNames();
                            subPropertyMapping = currentMappings.get(N_ADDITIONAL);
                            if(subPropertyMapping != null & additional != null && additional.length>0){
                                for(String value : additional){
                                    if(value != null && !value.isEmpty()){
                                        current.addNaturalText(subPropertyMapping.uri, StringUtils.chomp(value).trim());
                                    }
                                }
                            }
                            String[] prefixes = n.getPrefixes();
                            subPropertyMapping = currentMappings.get(N_PREFIX);
                            if(subPropertyMapping != null & prefixes != null && prefixes.length>0){
                                for(String value : prefixes){
                                    if(value != null && !value.isEmpty()){
                                        current.addNaturalText(subPropertyMapping.uri, StringUtils.chomp(value).trim());
                                    }
                                }
                            }
                            String[] suffixes = n.getSuffixes();
                            subPropertyMapping = currentMappings.get(N_SUFFIX);
                            if(subPropertyMapping != null & suffixes != null && suffixes.length>0){
                                for(String value : suffixes){
                                    if(value != null && !value.isEmpty()){
                                        current.addNaturalText(subPropertyMapping.uri, StringUtils.chomp(value).trim());
                                    }
                                }
                            }
                        }
                        break;
                    case ADR:
                        Address address = (Address)property;
                        if(address.getValue() != null &&
                                //check of the value does not only contain seperators (',')
                                !address.getValue().replace(';', ' ').trim().isEmpty()){
                            if(current == null){ //create new Representation
                                current = createSubRepresentation(rep, ".adr",
                                    representations.keySet(), mapping);
                                representations.put(current.getId(), current);
                            }
                            Mapping subPropertyMapping = currentMappings.get(ADR_POST_OFFICE_ADDRESS);
                            String value = address.getPoBox();
                            if(subPropertyMapping != null && value != null && !value.isEmpty()){
                                //add string -> this is no natural language text
                                current.add(subPropertyMapping.uri, StringUtils.chomp(value).trim());
                            }
                            value = address.getExtended();
                            subPropertyMapping = currentMappings.get(ADR_EXTENDED);
                            if(subPropertyMapping != null && value != null && !value.isEmpty()){
                                current.addNaturalText(subPropertyMapping.uri, StringUtils.chomp(value).trim());
                            }
                            value = address.getStreet();
                            subPropertyMapping = currentMappings.get(ADR_STREET);
                            if(subPropertyMapping != null && value != null && !value.isEmpty()){
                                current.addNaturalText(subPropertyMapping.uri, StringUtils.chomp(value).trim());
                            }
                            value = address.getLocality();
                            subPropertyMapping = currentMappings.get(ADR_LOCALITY);
                            if(subPropertyMapping != null && value != null && !value.isEmpty()){
                                current.addNaturalText(subPropertyMapping.uri, StringUtils.chomp(value).trim());
                            }
                            value = address.getRegion();
                            subPropertyMapping = currentMappings.get(ADR_REGION);
                            if(subPropertyMapping != null && value != null && !value.isEmpty()){
                                current.addNaturalText(subPropertyMapping.uri, StringUtils.chomp(value).trim());
                            }
                            value = address.getPostcode();
                            subPropertyMapping = currentMappings.get(ADR_POSTAL_CODE);
                            if(subPropertyMapping != null && value != null && !value.isEmpty()){
                                // add string -> this is no natural language text
                                current.add(subPropertyMapping.uri, StringUtils.chomp(value).trim());
                            }
                            value = address.getCountry();
                            subPropertyMapping = currentMappings.get(ADR_COUNTRY);
                            if(subPropertyMapping != null && value != null && !value.isEmpty()){
                                // add string -> based on the standard this should be the two letter code
                                current.add(subPropertyMapping.uri, StringUtils.chomp(value).trim());
                            }
                           
                        } //else empty ADR field -> ignore
                        break;
                    case ORG:
                        Org org = (Org)property;
                        String[] unitHierarchy = org.getValues();
                        Mapping orgNameMapping = currentMappings.get(OntologyMappings.ORG_NAME);
                        if(unitHierarchy.length>0 && orgNameMapping != null &&
                                unitHierarchy[0] != null && unitHierarchy[0].trim().length()>0){
                            String orgName = unitHierarchy[0];
                            if(current == null){ //create new Representation for the Organisation
                                //Note: this is an Entity and no sub-Resource!
View Full Code Here

Examples of org.b3log.latke.repository.jdbc.mapping.Mapping

            final String type = fieldDefinition.getType();
            if (type == null) {
                throw new RuntimeException("the type of fieldDefinitions should not be null");
            }
            final Mapping mapping = getJdbcTypeMapping().get(type);
            if (mapping != null) {
                createTableSql.append(mapping.toDataBaseSting(fieldDefinition)).append(",   ");

                if (fieldDefinition.getIsKey()) {
                    keyDefinitionList.add(fieldDefinition);
                }
            } else {
View Full Code Here

Examples of org.castor.cpa.test.framework.xml.Mapping

        Configuration config = _configurations.get(cfg);
       
        int count = config.getMappingCount();
        String[] mappings = new String[count];
        for (int i = 0; i < count; i++) {
            Mapping mapping = config.getMapping(i);
            if (mapping.getHref() == null) {
                throw new CPAConfigException("No mapping URL specified "
                        + "in mapping config '" + cfg + "'.");
            }
            mappings[i] = mapping.getHref();
        }
        return mappings;
    }
View Full Code Here

Examples of org.castor.jdo.conf.Mapping

     * @param mapping URL to retrieve mapping configuration file.
     * @return JDO Mapping configuration.
     * @deprecated Pass mapping URL's to createDatabase() methods instead.
     */
    public static Mapping createMapping(final String mapping) {
        Mapping mapConf = new Mapping();
        mapConf.setHref(mapping);
        return mapConf;
    }
View Full Code Here

Examples of org.codehaus.groovy.grails.orm.hibernate.cfg.Mapping

     * Is the given property an identity property? Checks the property as well as the custom domain class mapping
     * @param domainClassProperty domain clas property
     * @return true if the property is the/an identity property
     */
    public static boolean isIndentityProperty(GrailsDomainClassProperty domainClassProperty) {
        Mapping mapping = new GrailsDomainBinder().getMapping(domainClassProperty.getDomainClass().getClazz());
        if (mapping != null && mapping.getIdentity() instanceof CompositeIdentity) {
            CompositeIdentity identity = (CompositeIdentity) mapping.getIdentity();
            return Arrays.asList(identity.getPropertyNames()).contains(domainClassProperty.getName());
        }
        return domainClassProperty.isIdentity();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.