@Test public void testTagsFromAppInfo() throws Exception { XmlSchemaAppInfo xmlSchemaAppInfo = Mockito.mock(XmlSchemaAppInfo.class); Xsd2UmlPluginHost host = Mockito.mock(Xsd2UmlPluginHost.class); NodeList nodeList = Mockito.mock(NodeList.class); Element node = Mockito.mock(Element.class); Mockito.when(host.ensureTagDefinitionId(Mockito.anyString())).thenReturn(Identifier.random()); Mockito.when(xmlSchemaAppInfo.getMarkup()).thenReturn(nodeList); Mockito.when(nodeList.item(Matchers.anyInt())).thenReturn(node); Mockito.when(nodeList.getLength()).thenReturn(1); Mockito.when(node.getNodeType()).thenReturn(Node.ELEMENT_NODE); Mockito.when(node.getNamespaceURI()).thenReturn(SliMongoConstants.NAMESPACE_SLI); Mockito.when(node.getLocalName()).thenReturn("CollectionType"); Mockito.when(node.getChildNodes()).thenReturn(nodeList); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("naturalKey"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("applyNaturalKeys"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("PersonallyIdentifiableInfo"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("ReferenceType"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("ReadEnforcement"); Mockito.when(node.getTextContent()).thenReturn("READ_RESTRICTED"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("SecuritySphere"); Mockito.when(node.getTextContent()).thenReturn("Public"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("RelaxedBlacklist"); Mockito.when(node.getTextContent()).thenReturn("true"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("RestrictedForLogging"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("WriteEnforcement"); Mockito.when(node.getTextContent()).thenReturn("WRITE_RESTRICTED"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); Mockito.when(node.getLocalName()).thenReturn("schemaVersion"); Assert.assertNotNull(pluginForSLI.tagsFromAppInfo(xmlSchemaAppInfo, host)); }
@Override public List<TaggedValue> tagsFromAppInfo(final XmlSchemaAppInfo appInfo, final Xsd2UmlPluginHost host) { final List<TaggedValue> taggedValues = new LinkedList<TaggedValue>(); final NodeList markup = appInfo.getMarkup(); for (int i = 0; i < markup.getLength(); i++) { final Node node = markup.item(i); if (Node.ELEMENT_NODE == node.getNodeType()) { final Element element = (Element) node; final String namespace = element.getNamespaceURI(); final String localName = element.getLocalName(); final QName name = new QName(namespace, localName); if (SliMongoConstants.SLI_COLLECTION_NAME.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_COLLECTION_NAME); final String collectionName = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(collectionName, tagDefinition)); } else if (SliMongoConstants.SLI_ASSOCIATED_DATED_COLLECTION.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ASSOCIATED_DATED_COLLECTION); final String collectionName = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(collectionName, tagDefinition)); } else if (SliMongoConstants.SLI_NATURAL_KEY.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_NATURAL_KEY); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_APPLY_NATURAL_KEYS.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_APPLY_NATURAL_KEYS); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_SELF_REFERENCE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_SELF_REFERENCE); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_REFERENCE_TYPE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_REFERENCE); final String refereceType = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(refereceType, tagDefinition)); } else if (SliMongoConstants.SLI_PII.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_PII); final Boolean isPII = Boolean.valueOf(XmlTools.collapseWhitespace(stringValue(element .getChildNodes()))); taggedValues.add(new TaggedValue(isPII.toString(), tagDefinition)); } else if (SliMongoConstants.SLI_READ_ENFORCEMENT.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ENFORCE_READ); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); taggedValues.add(new TaggedValue(text, tagDefinition)); } else if (SliMongoConstants.SLI_SECURITY_SPHERE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_SECURITY_SPHERE); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("Public".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_RELAXEDBLACKLIST.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_RELAXED_BLACKLIST); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("true".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_RESTRICTED_FOR_LOGGING.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_RESTRICTED_FOR_LOGGING); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("true".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_WRITE_ENFORCEMENT.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ENFORCE_WRITE); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); taggedValues.add(new TaggedValue(text, tagDefinition)); } else if (SliMongoConstants.SLI_ASSOCIATION_KEY.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ASSOCIATION_KEY); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_BEGIN_DATE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_BEGIN_DATE); taggedValues.add(new TaggedValue(SliUmlConstants.TAGDEF_BEGIN_DATE, tagDefinition)); } else if (SliMongoConstants.SLI_END_DATE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_END_DATE); taggedValues.add(new TaggedValue(SliUmlConstants.TAGDEF_END_DATE, tagDefinition)); } else if (SliMongoConstants.SLI_FILTER_BEGIN_DATE_ON.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_FILTER_BEGIN_DATE_ON); taggedValues.add(new TaggedValue(stringValue(element.getChildNodes()), tagDefinition)); } else if (SliMongoConstants.SLI_FILTER_END_DATE_ON.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_FILTER_END_DATE_ON); taggedValues.add(new TaggedValue(stringValue(element.getChildNodes()), tagDefinition)); } } } return taggedValues; }
Xsd2UmlPluginForSLI extends Xsd2UmlPluginDefault { @Override public List<TaggedValue> tagsFromAppInfo(final XmlSchemaAppInfo appInfo, final Xsd2UmlPluginHost host) { final List<TaggedValue> taggedValues = new LinkedList<TaggedValue>(); final NodeList markup = appInfo.getMarkup(); for (int i = 0; i < markup.getLength(); i++) { final Node node = markup.item(i); if (Node.ELEMENT_NODE == node.getNodeType()) { final Element element = (Element) node; final String namespace = element.getNamespaceURI(); final String localName = element.getLocalName(); final QName name = new QName(namespace, localName); if (SliMongoConstants.SLI_COLLECTION_NAME.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_COLLECTION_NAME); final String collectionName = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(collectionName, tagDefinition)); } else if (SliMongoConstants.SLI_ASSOCIATED_DATED_COLLECTION.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ASSOCIATED_DATED_COLLECTION); final String collectionName = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(collectionName, tagDefinition)); } else if (SliMongoConstants.SLI_NATURAL_KEY.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_NATURAL_KEY); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_APPLY_NATURAL_KEYS.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_APPLY_NATURAL_KEYS); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_SELF_REFERENCE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_SELF_REFERENCE); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_REFERENCE_TYPE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_REFERENCE); final String refereceType = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(refereceType, tagDefinition)); } else if (SliMongoConstants.SLI_PII.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_PII); final Boolean isPII = Boolean.valueOf(XmlTools.collapseWhitespace(stringValue(element .getChildNodes()))); taggedValues.add(new TaggedValue(isPII.toString(), tagDefinition)); } else if (SliMongoConstants.SLI_READ_ENFORCEMENT.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ENFORCE_READ); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); taggedValues.add(new TaggedValue(text, tagDefinition)); } else if (SliMongoConstants.SLI_SECURITY_SPHERE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_SECURITY_SPHERE); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("Public".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_RELAXEDBLACKLIST.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_RELAXED_BLACKLIST); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("true".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_RESTRICTED_FOR_LOGGING.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_RESTRICTED_FOR_LOGGING); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("true".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_WRITE_ENFORCEMENT.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ENFORCE_WRITE); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); taggedValues.add(new TaggedValue(text, tagDefinition)); } else if (SliMongoConstants.SLI_ASSOCIATION_KEY.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ASSOCIATION_KEY); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_BEGIN_DATE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_BEGIN_DATE); taggedValues.add(new TaggedValue(SliUmlConstants.TAGDEF_BEGIN_DATE, tagDefinition)); } else if (SliMongoConstants.SLI_END_DATE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_END_DATE); taggedValues.add(new TaggedValue(SliUmlConstants.TAGDEF_END_DATE, tagDefinition)); } else if (SliMongoConstants.SLI_FILTER_BEGIN_DATE_ON.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_FILTER_BEGIN_DATE_ON); taggedValues.add(new TaggedValue(stringValue(element.getChildNodes()), tagDefinition)); } else if (SliMongoConstants.SLI_FILTER_END_DATE_ON.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_FILTER_END_DATE_ON); taggedValues.add(new TaggedValue(stringValue(element.getChildNodes()), tagDefinition)); } } } return taggedValues; } }
Xsd2UmlPluginForSLI extends Xsd2UmlPluginDefault { @Override public List<TaggedValue> tagsFromAppInfo(final XmlSchemaAppInfo appInfo, final Xsd2UmlPluginHost host) { final List<TaggedValue> taggedValues = new LinkedList<TaggedValue>(); final NodeList markup = appInfo.getMarkup(); for (int i = 0; i < markup.getLength(); i++) { final Node node = markup.item(i); if (Node.ELEMENT_NODE == node.getNodeType()) { final Element element = (Element) node; final String namespace = element.getNamespaceURI(); final String localName = element.getLocalName(); final QName name = new QName(namespace, localName); if (SliMongoConstants.SLI_COLLECTION_NAME.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_COLLECTION_NAME); final String collectionName = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(collectionName, tagDefinition)); } else if (SliMongoConstants.SLI_ASSOCIATED_DATED_COLLECTION.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ASSOCIATED_DATED_COLLECTION); final String collectionName = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(collectionName, tagDefinition)); } else if (SliMongoConstants.SLI_NATURAL_KEY.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_NATURAL_KEY); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_APPLY_NATURAL_KEYS.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_APPLY_NATURAL_KEYS); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_SELF_REFERENCE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_SELF_REFERENCE); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_REFERENCE_TYPE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_REFERENCE); final String refereceType = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(refereceType, tagDefinition)); } else if (SliMongoConstants.SLI_PII.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_PII); final Boolean isPII = Boolean.valueOf(XmlTools.collapseWhitespace(stringValue(element .getChildNodes()))); taggedValues.add(new TaggedValue(isPII.toString(), tagDefinition)); } else if (SliMongoConstants.SLI_READ_ENFORCEMENT.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ENFORCE_READ); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); taggedValues.add(new TaggedValue(text, tagDefinition)); } else if (SliMongoConstants.SLI_SECURITY_SPHERE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_SECURITY_SPHERE); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("Public".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_RELAXEDBLACKLIST.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_RELAXED_BLACKLIST); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("true".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_RESTRICTED_FOR_LOGGING.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_RESTRICTED_FOR_LOGGING); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("true".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_WRITE_ENFORCEMENT.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ENFORCE_WRITE); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); taggedValues.add(new TaggedValue(text, tagDefinition)); } else if (SliMongoConstants.SLI_ASSOCIATION_KEY.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ASSOCIATION_KEY); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_BEGIN_DATE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_BEGIN_DATE); taggedValues.add(new TaggedValue(SliUmlConstants.TAGDEF_BEGIN_DATE, tagDefinition)); } else if (SliMongoConstants.SLI_END_DATE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_END_DATE); taggedValues.add(new TaggedValue(SliUmlConstants.TAGDEF_END_DATE, tagDefinition)); } else if (SliMongoConstants.SLI_FILTER_BEGIN_DATE_ON.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_FILTER_BEGIN_DATE_ON); taggedValues.add(new TaggedValue(stringValue(element.getChildNodes()), tagDefinition)); } else if (SliMongoConstants.SLI_FILTER_END_DATE_ON.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_FILTER_END_DATE_ON); taggedValues.add(new TaggedValue(stringValue(element.getChildNodes()), tagDefinition)); } } } return taggedValues; } Xsd2UmlPluginForSLI(); }
Xsd2UmlPluginForSLI extends Xsd2UmlPluginDefault { @Override public List<TaggedValue> tagsFromAppInfo(final XmlSchemaAppInfo appInfo, final Xsd2UmlPluginHost host) { final List<TaggedValue> taggedValues = new LinkedList<TaggedValue>(); final NodeList markup = appInfo.getMarkup(); for (int i = 0; i < markup.getLength(); i++) { final Node node = markup.item(i); if (Node.ELEMENT_NODE == node.getNodeType()) { final Element element = (Element) node; final String namespace = element.getNamespaceURI(); final String localName = element.getLocalName(); final QName name = new QName(namespace, localName); if (SliMongoConstants.SLI_COLLECTION_NAME.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_COLLECTION_NAME); final String collectionName = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(collectionName, tagDefinition)); } else if (SliMongoConstants.SLI_ASSOCIATED_DATED_COLLECTION.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ASSOCIATED_DATED_COLLECTION); final String collectionName = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(collectionName, tagDefinition)); } else if (SliMongoConstants.SLI_NATURAL_KEY.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_NATURAL_KEY); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_APPLY_NATURAL_KEYS.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_APPLY_NATURAL_KEYS); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_SELF_REFERENCE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_SELF_REFERENCE); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_REFERENCE_TYPE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_REFERENCE); final String refereceType = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(refereceType, tagDefinition)); } else if (SliMongoConstants.SLI_PII.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_PII); final Boolean isPII = Boolean.valueOf(XmlTools.collapseWhitespace(stringValue(element .getChildNodes()))); taggedValues.add(new TaggedValue(isPII.toString(), tagDefinition)); } else if (SliMongoConstants.SLI_READ_ENFORCEMENT.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ENFORCE_READ); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); taggedValues.add(new TaggedValue(text, tagDefinition)); } else if (SliMongoConstants.SLI_SECURITY_SPHERE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_SECURITY_SPHERE); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("Public".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_RELAXEDBLACKLIST.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_RELAXED_BLACKLIST); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("true".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_RESTRICTED_FOR_LOGGING.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_RESTRICTED_FOR_LOGGING); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("true".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_WRITE_ENFORCEMENT.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ENFORCE_WRITE); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); taggedValues.add(new TaggedValue(text, tagDefinition)); } else if (SliMongoConstants.SLI_ASSOCIATION_KEY.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ASSOCIATION_KEY); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_BEGIN_DATE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_BEGIN_DATE); taggedValues.add(new TaggedValue(SliUmlConstants.TAGDEF_BEGIN_DATE, tagDefinition)); } else if (SliMongoConstants.SLI_END_DATE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_END_DATE); taggedValues.add(new TaggedValue(SliUmlConstants.TAGDEF_END_DATE, tagDefinition)); } else if (SliMongoConstants.SLI_FILTER_BEGIN_DATE_ON.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_FILTER_BEGIN_DATE_ON); taggedValues.add(new TaggedValue(stringValue(element.getChildNodes()), tagDefinition)); } else if (SliMongoConstants.SLI_FILTER_END_DATE_ON.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_FILTER_END_DATE_ON); taggedValues.add(new TaggedValue(stringValue(element.getChildNodes()), tagDefinition)); } } } return taggedValues; } Xsd2UmlPluginForSLI(); @Override List<TagDefinition> declareTagDefinitions(final Xsd2UmlPluginHost host); @Override String getAssociationEndTypeName(final ClassType classType, final Attribute attribute,
            final Xsd2UmlPluginHost host); @Override /** * The most reliable way to determine whether the attribute should be an association is to look for the tag that indicates * that the attribute should be treated as a reference. If there is no tag then we look for clues in the name of the attribute. */ boolean isAssociationEnd(final ClassType classType, final Attribute attribute, final Xsd2UmlPluginHost host); @Override String nameAssociation(final AssociationEnd lhs, final AssociationEnd rhs, final Xsd2UmlHostedPlugin host); @Override String nameFromSchemaTypeName(final QName name); @Override List<TaggedValue> tagsFromAppInfo(final XmlSchemaAppInfo appInfo, final Xsd2UmlPluginHost host); }
Xsd2UmlPluginForSLI extends Xsd2UmlPluginDefault { @Override public List<TaggedValue> tagsFromAppInfo(final XmlSchemaAppInfo appInfo, final Xsd2UmlPluginHost host) { final List<TaggedValue> taggedValues = new LinkedList<TaggedValue>(); final NodeList markup = appInfo.getMarkup(); for (int i = 0; i < markup.getLength(); i++) { final Node node = markup.item(i); if (Node.ELEMENT_NODE == node.getNodeType()) { final Element element = (Element) node; final String namespace = element.getNamespaceURI(); final String localName = element.getLocalName(); final QName name = new QName(namespace, localName); if (SliMongoConstants.SLI_COLLECTION_NAME.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_COLLECTION_NAME); final String collectionName = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(collectionName, tagDefinition)); } else if (SliMongoConstants.SLI_ASSOCIATED_DATED_COLLECTION.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ASSOCIATED_DATED_COLLECTION); final String collectionName = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(collectionName, tagDefinition)); } else if (SliMongoConstants.SLI_NATURAL_KEY.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_NATURAL_KEY); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_APPLY_NATURAL_KEYS.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_APPLY_NATURAL_KEYS); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_SELF_REFERENCE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_SELF_REFERENCE); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_REFERENCE_TYPE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_REFERENCE); final String refereceType = nameFromSchemaTypeName(new QName( XmlTools.collapseWhitespace(stringValue(element.getChildNodes())))); taggedValues.add(new TaggedValue(refereceType, tagDefinition)); } else if (SliMongoConstants.SLI_PII.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_PII); final Boolean isPII = Boolean.valueOf(XmlTools.collapseWhitespace(stringValue(element .getChildNodes()))); taggedValues.add(new TaggedValue(isPII.toString(), tagDefinition)); } else if (SliMongoConstants.SLI_READ_ENFORCEMENT.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ENFORCE_READ); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); taggedValues.add(new TaggedValue(text, tagDefinition)); } else if (SliMongoConstants.SLI_SECURITY_SPHERE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_SECURITY_SPHERE); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("Public".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_RELAXEDBLACKLIST.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_RELAXED_BLACKLIST); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("true".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_RESTRICTED_FOR_LOGGING.equals(name)) { final Identifier tagDefinition = host .ensureTagDefinitionId(SliUmlConstants.TAGDEF_RESTRICTED_FOR_LOGGING); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); if ("true".equals(text)) { taggedValues.add(new TaggedValue(text, tagDefinition)); } else { throw new AssertionError("Unexpected value for appinfo: " + name + " => " + text); } } else if (SliMongoConstants.SLI_WRITE_ENFORCEMENT.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ENFORCE_WRITE); final String text = XmlTools.collapseWhitespace(stringValue(element.getChildNodes())); taggedValues.add(new TaggedValue(text, tagDefinition)); } else if (SliMongoConstants.SLI_ASSOCIATION_KEY.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_ASSOCIATION_KEY); taggedValues.add(new TaggedValue("true", tagDefinition)); } else if (SliMongoConstants.SLI_BEGIN_DATE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_BEGIN_DATE); taggedValues.add(new TaggedValue(SliUmlConstants.TAGDEF_BEGIN_DATE, tagDefinition)); } else if (SliMongoConstants.SLI_END_DATE.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_END_DATE); taggedValues.add(new TaggedValue(SliUmlConstants.TAGDEF_END_DATE, tagDefinition)); } else if (SliMongoConstants.SLI_FILTER_BEGIN_DATE_ON.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_FILTER_BEGIN_DATE_ON); taggedValues.add(new TaggedValue(stringValue(element.getChildNodes()), tagDefinition)); } else if (SliMongoConstants.SLI_FILTER_END_DATE_ON.equals(name)) { final Identifier tagDefinition = host.ensureTagDefinitionId(SliUmlConstants.TAGDEF_FILTER_END_DATE_ON); taggedValues.add(new TaggedValue(stringValue(element.getChildNodes()), tagDefinition)); } } } return taggedValues; } Xsd2UmlPluginForSLI(); @Override List<TagDefinition> declareTagDefinitions(final Xsd2UmlPluginHost host); @Override String getAssociationEndTypeName(final ClassType classType, final Attribute attribute,
            final Xsd2UmlPluginHost host); @Override /** * The most reliable way to determine whether the attribute should be an association is to look for the tag that indicates * that the attribute should be treated as a reference. If there is no tag then we look for clues in the name of the attribute. */ boolean isAssociationEnd(final ClassType classType, final Attribute attribute, final Xsd2UmlPluginHost host); @Override String nameAssociation(final AssociationEnd lhs, final AssociationEnd rhs, final Xsd2UmlHostedPlugin host); @Override String nameFromSchemaTypeName(final QName name); @Override List<TaggedValue> tagsFromAppInfo(final XmlSchemaAppInfo appInfo, final Xsd2UmlPluginHost host);  }