/** * @see * org.teiid.designer.core.types.DatatypeManager#getEnterpriseExtensionsMap(org.eclipse.emf.ecore.EObject) */ @Override public Map getEnterpriseExtensionsMap(EObject type) { Map result = Collections.EMPTY_MAP; if (type instanceof XSDSimpleTypeDefinition) { // Get the annotation for the type XSDAnnotation annotation = ((XSDSimpleTypeDefinition) type).getAnnotation(); if (annotation == null) { return null; } // Iterator over the appInfos and add any attributes to the result collection result = new HashMap(); final Iterator appInfos = annotation.getApplicationInformation().iterator(); while (appInfos.hasNext()) { final Element appInfo = (Element) appInfos.next(); if (appInfo.getAttributes() != null && appInfo.getAttributes().getLength() > 0) { final int length = appInfo.getAttributes().getLength(); final NamedNodeMap map = appInfo.getAttributes(); for (int i = 0; i < length; i++) { final Node mapNode = map.item(i); if (mapNode != null) { result.put(mapNode.getNodeName(), mapNode.getNodeValue()); } } } } } return result; }
/** @see org.teiid.designer.core.types.DatatypeManager#getUUID(org.eclipse.emf.ecore.EObject) */ @Override public ObjectID getUuid(EObject type) { if (type instanceof XSDSimpleTypeDefinition) { XSDAnnotation annotation = ((XSDSimpleTypeDefinition) type).getAnnotation(); if (annotation == null) { return null; } final Iterator appInfos = annotation.getApplicationInformation().iterator(); while (appInfos.hasNext()) { final Element appInfo = (Element) appInfos.next(); final String uuid = appInfo.getAttribute("UUID"); // $NON-NLS-1$ if (uuid != null && uuid.trim().length() > 0) { try { return IDGenerator.getInstance().stringToObject(uuid); } catch (InvalidIDException e) { return null; } } return null; } } return null; }
private void resetXsdSimpleTypeUuids(final Resource resource) throws Exception { if (resource instanceof XSDResourceImpl) { final XSDResourceImpl xsdResource = (XSDResourceImpl) resource; final XSDSchema schema = xsdResource.getSchema(); if (schema != null) { for (final Iterator iter = schema.getContents().iterator(); iter.hasNext(); ) { EObject eObj = (EObject) iter.next(); // Only process global simple type definitions ... if (eObj instanceof XSDSimpleTypeDefinition) { final XSDSimpleTypeDefinition type = (XSDSimpleTypeDefinition) eObj; // Get the application information ... final XSDAnnotation annotation = type.getAnnotation(); // If no annotation exists then no UUID attribute exists to reset ... if (annotation == null) { continue; } for (final Iterator appInfos = annotation.getApplicationInformation().iterator(); appInfos.hasNext(); ) { final Element appInfo = (Element) appInfos.next(); String uuid = appInfo.getAttribute(UUID_ATTRIBUTE_NAME); if (uuid != null) { uuid = IDGenerator.getInstance().create().toString(); appInfo.setAttribute(UUID_ATTRIBUTE_NAME, uuid); uuid = appInfo.getAttribute(UUID_ATTRIBUTE_NAME); } } } } } } }
protected Object[] getXSDAnnotationChildren(XSDAnnotation parent) { ArrayList<Object> list = new ArrayList<Object>(); list.addAll(parent.getUserInformation()); list.addAll(parent.getApplicationInformation()); return list.toArray(new Object[list.size()]); }
public static XSDAnnotation createAppInfo( XSDElementDeclaration elementDeclaration, String appInfo) { if (appInfo != null) { XSDAnnotation annotation = XSDFactory.eINSTANCE.createXSDAnnotation(); elementDeclaration.setAnnotation(annotation); org.w3c.dom.Element element = annotation.createApplicationInformation("http://www.edna-site.org/dsl2xsd"); annotation.getElement().appendChild(element); element.appendChild(element.getOwnerDocument().createTextNode(appInfo)); return annotation; } return null; }
public static XSDAnnotation createDocumentation( XSDElementDeclaration elementDeclaration, String documentation) { // see // http://download.eclipse.org/modeling/mdt/xsd/javadoc/2.3.0/org/eclipse/xsd/util/XSDPrototypicalSchema.html // (search "annotation.createUserInformation") if (documentation != null) { XSDAnnotation annotation = XSDFactory.eINSTANCE.createXSDAnnotation(); elementDeclaration.setAnnotation(annotation); org.w3c.dom.Element docElement = annotation.createUserInformation(null); annotation.getElement().appendChild(docElement); docElement.appendChild(docElement.getOwnerDocument().createTextNode(documentation)); return annotation; } return null; }
/** @see org.teiid.designer.core.types.DatatypeManager#getUUID(org.eclipse.emf.ecore.EObject) */ @Override public String getUuidString(EObject type) { if (type instanceof XSDSimpleTypeDefinition) { XSDAnnotation annotation = ((XSDSimpleTypeDefinition) type).getAnnotation(); if (annotation == null) { return null; } final Iterator appInfos = annotation.getApplicationInformation().iterator(); while (appInfos.hasNext()) { final Element appInfo = (Element) appInfos.next(); final String uuid = appInfo.getAttribute("UUID"); // $NON-NLS-1$ if (uuid != null && uuid.trim().length() > 0) { return uuid; } } return null; } return null; }
protected void processAnnotations(List<XSDAnnotation> annotations, Node parentNode) throws RepositoryException { assert annotations != null; StringBuilder sb = new StringBuilder(); for (XSDAnnotation annotation : annotations) { for (Object obj : annotation.getUserInformation()) { Element element = (Element) obj; if (element.getLocalName().equals("documentation")) { String content = element.getTextContent(); if (content != null) sb.append(content); } } sb.append(System.getProperty("line.separator")); } if (sb.length() != 0) { String content = sb.toString(); content = content.trim(); if (content.length() != 0) { parentNode.setProperty(DESCRIPTION, content); } } }
protected void processAnnotation(XSDAnnotation annotation, Node node) throws RepositoryException { if (annotation == null) { return; } StringBuilder sb = new StringBuilder(); for (Object obj : annotation.getUserInformation()) { Element element = (Element) obj; if (element.getLocalName().equals("documentation")) { String content = element.getTextContent(); if (content != null) sb.append(content); } } if (sb.length() != 0) { String content = sb.toString(); content = content.trim(); if (content.length() != 0) { node.setProperty(DESCRIPTION, content); } } }
public static String getDocumentationText(XSDAnnotation annotation) { org.w3c.dom.Element docElement = annotation.getUserInformation().get(0); String doc = docElement.getTextContent(); return doc; }