protected AbstractStructuredDataAccessPointAdapter wrapElement(TypedXPath xPath, Object value) { AbstractStructuredDataAccessPointAdapter adapter = null; if (null != adapters) { // was this value wrapped before? adapter = (AbstractStructuredDataAccessPointAdapter) adapters.get(xPath); } if (null == adapter) { if (xPath.isList()) { adapter = new StructuredDataListAccessor(xPath, null, isConstant()); } else if (BigData.NULL == xPath.getType() || xPath.getChildXPaths().size() > 0) { adapter = new StructuredDataMapAccessor(xPath, null, isConstant()); } if (null == adapters) { this.adapters = CollectionUtils.newMap(); } adapters.put(xPath, adapter); } if (null != adapter) { if (adapter.getValue() != value) { adapter.bindValue(value); } } return adapter; }
protected TypedXPath getChildXPath(String name) { TypedXPath result = null; if (null != xPath) { // if the "@" property is requested, assume it points to the // content of the current element if (StructuredDataConverter.NODE_VALUE_KEY.equals(name)) { return this.xPath; } // TODO evaluate type of attribute, if defined if (xPath.isList() && "[]".equals(name)) { return new ListValuedXPathAdapter(xPath); } result = xPath.getChildXPath(name); if (result == null && !name.startsWith(StructuredDataConverter.NODE_VALUE_KEY)) { // try to search for an attribute xpath if no element xpath was found // this allows to access attributes using element.attributeName // as well as element["@attributeName" result = xPath.getChildXPath(StructuredDataConverter.NODE_VALUE_KEY + name); } } return result; }
/** * @param dataMapping * @param maPath * @return */ private Path createStructureDataMapping(DataMapping dataMapping, ManualActivityPath maPath) { Set<TypedXPath> xpaths = ModelUtils.getXPaths(getModel(), dataMapping); for (TypedXPath path : xpaths) { if (path.getParentXPath() == null) { return new XsdPath( maPath, path, dataMapping.getId(), Direction.IN == dataMapping.getDirection()); } } return null; }
/** * @param dataMapping * @param allInMappings * @param maPath * @return */ private Path createDMSDataMapping( DataMapping dataMapping, List<Object> allInMappings, ManualActivityPath maPath) { if (ModelUtils.isDocumentType(getModel(), dataMapping)) // Document { if (!isWriteOnly(dataMapping, allInMappings)) { DocumentType documentType = org.eclipse.stardust.ui.web.viewscommon.utils.ModelUtils.getDocumentTypeFromData( getModel(), getModel().getData(dataMapping.getDataId())); if (documentType == null) { trace.debug( "Could not resolve type for Document:, " + dataMapping.getQualifiedId() + ". It may be set defualt by design"); } return new DocumentPath( maPath, dataMapping.getId(), documentType, null, Direction.IN == dataMapping.getDirection()); } else { trace.warn( "Skipping Data Mapping - Found it as Write Only - " + dataMapping.getId() + ":" + dataMapping.getName()); } } else if (ModelUtils.isFolderType(getModel(), dataMapping)) // Folder { // Skip, Not supported } else // Only Meta Data { Path docTypePath = null; Data documentData = getModel().getData(dataMapping.getDataId()); String metaDataTypeId = (String) documentData.getAttribute(DmsConstants.RESOURCE_METADATA_SCHEMA_ATT); if (StringUtils.isNotEmpty(metaDataTypeId)) { TypeDeclaration typeDeclaration = getModel().getTypeDeclaration(metaDataTypeId); Set<TypedXPath> allXPaths = StructuredTypeRtUtils.getAllXPaths(getModel(), typeDeclaration); for (TypedXPath path : allXPaths) { if ("properties".equals(dataMapping.getDataPath())) // Mapping to entire properties { if (null == path.getParentXPath()) { docTypePath = new XsdPath( maPath, path, dataMapping.getId(), Direction.IN == dataMapping.getDirection()); break; } } else if (dataMapping .getDataPath() .equals("properties/" + path.getXPath())) // Mapping to nested item in properties { docTypePath = new XsdPath( maPath, path, dataMapping.getId(), Direction.IN == dataMapping.getDirection()); break; } } } // if null means - Mapping to documenmt's attributes e.g. id, owner, etc if (null == docTypePath) { // This is the only possibility, but still check if (ModelUtils.isPrimitiveType(getModel(), dataMapping)) { docTypePath = createPrimitiveDataMapping(dataMapping, maPath); } } return docTypePath; } return null; }