Examples of 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
  • org.exolab.castor.mapping.xml.FieldMapping
    @version $Revision: 1.1.1.1 $ $Date: 2003/03/03 07:08:35 $
  • org.kitesdk.data.FieldMapping
    Represents how to store a Schema field. @since 0.14.0

  • Examples of org.apache.openjpa.jdbc.meta.FieldMapping

        }

        public Object toDataStoreValue(Select sel, ExpContext ctx, ExpState state,
            Object val) {
            PathExpState pstate = (PathExpState) state;
            FieldMapping field = (pstate.cmpfield != null) ? pstate.cmpfield
                : pstate.field;
            if (isXPath())
                return val;
            if (field != null) {
                if (_key)
                    return field.toKeyDataStoreValue(val, ctx.store);
                if (field.getElement().getDeclaredTypeCode() != JavaTypes.OBJECT)
                    return field.toDataStoreValue(val, ctx.store);

                val = field.getExternalValue(val, ctx.store.getContext());
                return field.toDataStoreValue(val, ctx.store);
            }
            return _class.toDataStoreValue(val, _class.getPrimaryKeyColumns(),
                ctx.store);
        }
    View Full Code Here

    Examples of org.apache.openjpa.jdbc.meta.FieldMapping

            // we eventually call appendIsEmpty or appendIsNull rather than appendTo
        }

        public void verifyIndexedField() {
            Action lastAction = (Action) lastFieldAction();
            FieldMapping fm = (FieldMapping) lastAction.data;
            if (fm.getOrderColumn() == null)
                throw new UserException(_loc.get("no-order-column", fm.getName()));
        }
    View Full Code Here

    Examples of org.apache.openjpa.jdbc.meta.FieldMapping

        private void endMapKeyTemporal() {
            String temp = currentText();
            TemporalType _mapKeyTemporal = null;
            if (!StringUtils.isEmpty(temp))
                _mapKeyTemporal = Enum.valueOf(TemporalType.class, temp);
            FieldMapping fm = (FieldMapping) currentElement();
            List<Column> cols = fm.getKeyMapping().getValueInfo().getColumns();
            if (cols.isEmpty()) {
                cols = Arrays.asList(new Column[]{ new Column() });
                fm.getKeyMapping().getValueInfo().setColumns(cols);
            }

            Column col = (Column) cols.get(0);
            switch (_mapKeyTemporal) {
                case DATE:
    View Full Code Here

    Examples of org.apache.openjpa.jdbc.meta.FieldMapping

            String text = currentText();
            if (StringUtils.isEmpty(text))
                return;
            EnumType type = Enum.valueOf(EnumType.class, text);

            FieldMapping fm = (FieldMapping) currentElement();
            String strat = EnumValueHandler.class.getName() + "(StoreOrdinal="
                + String.valueOf(type == EnumType.ORDINAL) + ")";
            if (fm.isElementCollection())
                fm.getElementMapping().getValueInfo().setStrategy(strat);
            else
                fm.getValueInfo().setStrategy(strat);
        }
    View Full Code Here

    Examples of org.apache.openjpa.jdbc.meta.FieldMapping

            String text = currentText();
            if (StringUtils.isEmpty(text))
                return;
            EnumType type = Enum.valueOf(EnumType.class, text);

            FieldMapping fm = (FieldMapping) currentElement();
            String strat = EnumValueHandler.class.getName() + "(StoreOrdinal="
                + String.valueOf(type == EnumType.ORDINAL) + ")";
            fm.getKeyMapping().getValueInfo().setStrategy(strat);
        }
    View Full Code Here

    Examples of org.apache.openjpa.jdbc.meta.FieldMapping

        @Override
        protected void startFieldMapping(FieldMetaData field, Attributes attrs)
            throws SAXException {
            super.startFieldMapping(field, attrs);
            if (getAnnotationParser() != null) {
                FieldMapping fm = (FieldMapping) field;
                fm.getMappingInfo().clear();
                fm.getValueInfo().clear();
                fm.getElementMapping().getValueInfo().clear();
                fm.getKeyMapping().getValueInfo().clear();
            }
        }
    View Full Code Here

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

            // 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, nsPrefixService);
                    if (mapping != null) {
                        log.debug("   - add FieldMapping {}", mapping);
                        fieldMappings.addMapping(mapping);
                    }
    View Full Code Here

    Examples of org.exolab.castor.mapping.xml.FieldMapping

            }

            XMLClassDescriptor xmlClass;
            FieldDescriptor[] fields;
            ClassMapping classMap;
            FieldMapping fieldMap;

            boolean introspected = false;
            try {
                if (_forceIntrospection) {
                    xmlClass = _internalContext.getIntrospector().generateClassDescriptor(cls);
                    introspected = true;
                } else {
                    xmlClass = (XMLClassDescriptor) _internalContext.getXMLClassDescriptorResolver().resolve(cls);
                    introspected = _internalContext.getIntrospector().introspected(xmlClass);
                }
            } catch (Exception except) {
                throw new MappingException(except);
            }
            classMap = new ClassMapping();
            classMap.setName(cls.getName());
            classMap.setDescription("Default mapping for class " + cls.getName());

            // -- prevent default access from showing up in the mapping
            classMap.setAccess(null);

            // -- map-to
            MapTo mapTo = new MapTo();
            mapTo.setXml(xmlClass.getXMLName());
            mapTo.setNsUri(xmlClass.getNameSpaceURI());
            mapTo.setNsPrefix(xmlClass.getNameSpacePrefix());
            classMap.setMapTo(mapTo);

            // -- add mapping to hashtable before processing
            // -- fields so we can do recursive processing
            _mappings.put(cls, classMap);

            fields = xmlClass.getFields();
            for (int i = 0; i < fields.length; ++i) {
                FieldDescriptor fdesc = fields[i];

                String fieldName = fdesc.getFieldName();

                boolean isContainer = false;
                // -- check for collection wrapper
                if (introspected && fieldName.startsWith("##container")) {
                    fdesc = fdesc.getClassDescriptor().getFields()[0];
                    fieldName = fdesc.getFieldName();
                    isContainer = true;
                }

                Class fieldType = fdesc.getFieldType();

                // -- check to make sure we can find the accessors...
                // -- if we used introspection we don't need to
                // -- enter this block...only when descriptors
                // -- were generated using the source code generator
                // -- or by hand.
                if ((!introspected) && fieldName.startsWith(UNDERSCORE)) {
                    // -- check to see if we need to remove underscore
                    if (!_mappingLoader.canFindAccessors(cls, fieldName, fieldType)) {
                        fieldName = fieldName.substring(1);
                    }

                    // -- check to see if we need to remove "List" prefix
                    // -- used by generated source code
                    if (!_mappingLoader.canFindAccessors(cls, fieldName, fieldType)) {
                        if (fieldName.endsWith("List")) {
                            int len = fieldName.length() - 4;
                            String tmpName = fieldName.substring(0, len);
                            if (_mappingLoader.canFindAccessors(cls, tmpName, fieldType)) {
                                fieldName = tmpName;
                            }
                        }
                    }
                }

                fieldMap = new FieldMapping();
                fieldMap.setName(fieldName);

                // -- unwrap arrays of objects
                boolean isArray = fieldType.isArray();
                while (fieldType.isArray()) {
                    fieldType = fieldType.getComponentType();
                }

                // -- To prevent outputing of optional fields...check
                // -- for value first before setting
                if (fdesc.isRequired()) {
                    fieldMap.setRequired(true);
                }
                if (fdesc.isTransient()) {
                    fieldMap.setTransient(true);
                }
                if (fdesc.isMultivalued()) {
                    // -- special case for collections
                    if (isContainer) {
                        // -- backwards than what you'd expect, but
                        // -- if the collection had a "container" wrapper
                        // -- then we specify container="false" in the
                        // -- mapping file.
                        fieldMap.setContainer(false);
                    }

                    // -- try to guess collection type
                    if (isArray) {
                        fieldMap.setCollection(FieldMappingCollectionType.ARRAY);
                    } else {
                        // -- if the fieldType is the collection, then set
                        // appropriate
                        // -- collection type
                        String colName = CollectionHandlers.getCollectionName(fieldType);
                        if (colName != null) {
                            fieldMap.setCollection(FieldMappingCollectionType.valueOf(colName));
                            fieldType = Object.class;
                        } else if (_mappingLoader.returnsArray(cls, fieldName, fieldType)) {
                            // -- help maintain compatibility with generated
                            // descriptors
                            fieldMap.setCollection(FieldMappingCollectionType.ARRAY);
                        } else {
                            fieldMap.setCollection(FieldMappingCollectionType.ENUMERATE);
                        }
                    }
                }

                // -- fieldType
                fieldMap.setType(fieldType.getName());

                // -- handle XML Specific information
                fieldMap.setBindXml(new BindXml());
                fieldMap.getBindXml().setName(((XMLFieldDescriptor) fdesc).getXMLName());
                fieldMap.getBindXml().setNode(
                        BindXmlNodeType.valueOf(((XMLFieldDescriptor) fields[i]).getNodeType()
                                .toString()));
                if (classMap.getClassChoice() == null) {
                    classMap.setClassChoice(new ClassChoice());
                }
    View Full Code Here

    Examples of org.kitesdk.data.FieldMapping

      }

      public SingleFieldEntityFilter(EntitySchema entitySchema,
          EntitySerDe<?> entitySerDe, String fieldName, Object filterValue,
          CompareFilter.CompareOp equalityOperator) {
        FieldMapping fieldMapping = entitySchema.getColumnMappingDescriptor()
            .getFieldMapping(fieldName);
        if (fieldMapping.getMappingType() != MappingType.COLUMN) {
          throw new DatasetException(
              "SingleColumnValueFilter only compatible with COLUMN mapping types.");
        }

        byte[] family = fieldMapping.getFamily();
        byte[] qualifier = fieldMapping.getQualifier();
        byte[] comparisonBytes = entitySerDe.serializeColumnValueToBytes(fieldName,
            filterValue);

        this.filter = new SingleColumnValueFilter(family, qualifier,
            equalityOperator, comparisonBytes);
    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.