/** * Adds a new generic {@link Relationship} to the artifact. * @param artifact * @param relationshipType * @param targetUUID * @return the created {@link Relationship} */ public static Relationship addGenericRelationship(BaseArtifactType artifact, String relationshipType, String targetUUID) { Relationship relationship = null; for (Relationship r : artifact.getRelationship()) { if (r.getRelationshipType().equals(relationshipType)) { relationship = r; break; } } if (relationship == null) { relationship = new Relationship(); relationship.setRelationshipType(relationshipType); artifact.getRelationship().add(relationship); } // TODO check for duplicates first? if (targetUUID != null) { Target target = new Target(); target.setValue(targetUUID); relationship.getRelationshipTarget().add(target); } return relationship; }
/** * Updates the generic artifact relationships. * @param artifact * @throws Exception */ private void updateGenericRelationships(BaseArtifactType artifact) throws Exception { for (Relationship relationship : artifact.getRelationship()) { if (relationship.getRelationshipTarget().size() > 0) { setRelationships(relationship.getRelationshipType(), RelationshipType.GENERIC, relationship.getRelationshipTarget(), relationship.getOtherAttributes()); } } }
/** * @see org.overlord.sramp.common.visitors.HierarchicalArtifactVisitorAdapter#visitBase(org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactType) */ @Override protected void visitBase(BaseArtifactType artifact) { List<Relationship> relationships = artifact.getRelationship(); if (relationships != null) { for (Relationship relationship : relationships) { String type = relationship.getRelationshipType(); List<Target> targets = relationship.getRelationshipTarget(); visitRelationships(type, targets); } } super.visitBase(artifact); }
/** * @see org.overlord.sramp.integration.switchyard.model.SwitchYardArtifactVisitor#visitService(org.oasis_open.docs.s_ramp.ns.s_ramp_v1.ExtendedArtifactType) */ @Override public void visitService(ExtendedArtifactType artifact) { // Handle unresolved "implements" relationships Relationship relationship = SrampModelUtils.getGenericRelationship(artifact, SwitchYardModel.REL_IMPLEMENTS); if (relationship != null && relationship.getOtherAttributes().containsKey(SwitchYardXmlDeriver.UNRESOLVED_REF)) { String ref = relationship.getOtherAttributes().remove(SwitchYardXmlDeriver.UNRESOLVED_REF); if (ref.startsWith("java:")) { //$NON-NLS-1$ String refInterfaceName = ref.substring(5); BaseArtifactType artifactRef = findJavaInterfaceArtifact(refInterfaceName); if (artifactRef != null) { Target target = new Target(); target.setValue(artifactRef.getUuid()); relationship.getRelationshipTarget().add(target); } } else if (ref.startsWith("wsdl:")) { //$NON-NLS-1$ String refWsdl = ref.substring(5); BaseArtifactType artifactRef = findWsdlArtifact(refWsdl); if (artifactRef != null) { Target target = new Target(); target.setValue(artifactRef.getUuid()); relationship.getRelationshipTarget().add(target); } } } }
Relationship relationship = new Relationship(); relationship.setRelationshipType(rtype); if (rNode.hasProperty("sramp:relationshipTarget")) { //$NON-NLS-1$ Property property = rNode.getProperty("sramp:relationshipTarget"); //$NON-NLS-1$ Target target = new Target(); target.setValue(targetUUID); relationship.getRelationshipTarget().add(target);
/** * Gets the generic relationship from the artifact (by type). * @param artifact the s-ramp artifact * @param relationshipType the relationship type * @return the Relationship or null if not found */ public static Relationship getGenericRelationship(BaseArtifactType artifact, String relationshipType) { for (Relationship relationship : artifact.getRelationship()) { if (relationship.getRelationshipType().equals(relationshipType)) { return relationship; } } return null; }
/** * Create an instance of {@link Relationship } * */ public Relationship createRelationship() { return new Relationship(); }
relationship.getOtherAttributes().put(UNRESOLVED_REF, name); relationship.getOtherAttributes().put(UNRESOLVED_REF, "class:" + node.getAttribute("class")); //$NON-NLS-1$ //$NON-NLS-2$ relationship.getOtherAttributes().put(UNRESOLVED_REF, "bean:" + node.getAttribute("bean")); //$NON-NLS-1$ //$NON-NLS-2$
/** * Updates the generic artifact relationships. * @param artifact * @throws RepositoryException */ private void updateGenericRelationships(BaseArtifactType artifact) throws Exception { // Create/Update all the relationships included in the artifact Set<String> updatedRelationshipTypes = new HashSet<String>(); for (Relationship relationship : artifact.getRelationship()) { setRelationships(relationship.getRelationshipType(), -1, 0, null, true, relationship.getRelationshipTarget()); updatedRelationshipTypes.add(relationship.getRelationshipType()); } // Now remove any relationships that weren't just updated or created (the ones // not included on the artifact but that have existing JCR nodes). NodeIterator existingNodes = this.jcrNode.getNodes(); while (existingNodes.hasNext()) { Node node = existingNodes.nextNode(); // Only roemove generic relationships if (node.isNodeType("sramp:relationship") && node.hasProperty("sramp:generic") //$NON-NLS-1$ //$NON-NLS-2$ && node.getProperty("sramp:generic").getBoolean()) { //$NON-NLS-1$ String type = node.getProperty("sramp:relationshipType").getString(); //$NON-NLS-1$ // If this relationship type was *not* updated above, then remove it because // it's not included in the latest artifact meta-data if (!updatedRelationshipTypes.contains(type)) { node.remove(); } } } }
/** * @see org.overlord.sramp.integration.switchyard.model.SwitchYardArtifactVisitor#visitComponentService(org.oasis_open.docs.s_ramp.ns.s_ramp_v1.ExtendedArtifactType) */ @Override public void visitComponentService(ExtendedArtifactType artifact) { // Handle unresolved "implements" relationships Relationship relationship = SrampModelUtils.getGenericRelationship(artifact, SwitchYardModel.REL_IMPLEMENTS); if (relationship != null && relationship.getOtherAttributes().containsKey(SwitchYardXmlDeriver.UNRESOLVED_REF)) { String ref = relationship.getOtherAttributes().remove(SwitchYardXmlDeriver.UNRESOLVED_REF); if (ref.startsWith("java:")) { //$NON-NLS-1$ String refInterfaceName = ref.substring(5); BaseArtifactType artifactRef = findJavaInterfaceArtifact(refInterfaceName); if (artifactRef != null) { Target target = new Target(); target.setValue(artifactRef.getUuid()); relationship.getRelationshipTarget().add(target); } } else if (ref.startsWith("wsdl:")) { //$NON-NLS-1$ String refWsdl = ref.substring(5); BaseArtifactType artifactRef = findWsdlArtifact(refWsdl); if (artifactRef != null) { Target target = new Target(); target.setValue(artifactRef.getUuid()); relationship.getRelationshipTarget().add(target); } } } }
xsdDocument.getImportedXsds().add(importedXsdTarget); Relationship relationship = new Relationship(); relationship.setRelationshipType("similarXsds"); Target relationshipTarget = new Target(); relationshipTarget.setValue("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaa6b"); new QName("xlink:href"), "http://example.org/s-ramp/xsd/XsdDocument/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaa6b"); relationship.getRelationshipTarget().add(relationshipTarget); new QName("xlink:href"), "http://example.org/s-ramp/xsd/XsdDocument/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaa6c"); relationship.getRelationshipTarget().add(relationshipTarget2); xsdDocument.getRelationship().add(relationship);
/** * Gets the generic relationship from the artifact (by type). * @param artifact the s-ramp artifact * @param relationshipType the relationship type * @return the Relationship or null if not found */ public static Relationship getGenericRelationship(BaseArtifactType artifact, String relationshipType) { for (Relationship relationship : artifact.getRelationship()) { if (relationship.getRelationshipType().equals(relationshipType)) { return relationship; } } return null; }
/** * Create an instance of {@link Relationship } * */ public Relationship createRelationship() { return new Relationship(); }
if (node.hasAttribute("class")) { //$NON-NLS-1$ Relationship relationship = SrampModelUtils.addGenericRelationship(transformerArtifact, SwitchYardModel.REL_IMPLEMENTED_BY, null); relationship.getOtherAttributes().put(UNRESOLVED_REF, "class:" + node.getAttribute("class")); //$NON-NLS-1$ //$NON-NLS-2$ relationship.getOtherAttributes().put(UNRESOLVED_REF, "bean:" + node.getAttribute("bean")); //$NON-NLS-1$ //$NON-NLS-2$ relationship.getOtherAttributes().put(UNRESOLVED_REF, "xslt:" + node.getAttribute("xsltFile")); //$NON-NLS-1$ //$NON-NLS-2$ relationship.getOtherAttributes().put(UNRESOLVED_REF, "smooks:" + node.getAttribute("config")); //$NON-NLS-1$ //$NON-NLS-2$ relationship.getOtherAttributes().put(UNRESOLVED_REF, node.getAttribute("from")); //$NON-NLS-1$ relationship.getOtherAttributes().put(UNRESOLVED_REF, node.getAttribute("to")); //$NON-NLS-1$
Relationship relationship = null; for (Relationship r : artifact.getRelationship()) { if (r.getRelationshipType().equals(relationshipType)) { relationship = r; break; relationship = new Relationship(); relationship.setRelationshipType(relationshipType); artifact.getRelationship().add(relationship); target.setValue(targetUUID); target.getOtherAttributes().putAll(targetOtherAttributes); relationship.getRelationshipTarget().add(target); relationship.getOtherAttributes().putAll(relationshipOtherAttributes);
/** * @see HierarchicalArtifactVisitor#visitBase(org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactType) */ @Override protected void visitBase(BaseArtifactType artifact) { // expansion String archiveUuid = artifact.getOtherAttributes().get(ArtificerConstants.ARTIFICER_EXPANDED_FROM_ARCHIVE_UUID_QNAME); if (StringUtils.isNotBlank(archiveUuid)) { visitRelationship("expandedFromArchive", archiveUuid, false); } List<Relationship> relationships = artifact.getRelationship(); if (relationships != null) { for (Relationship relationship : relationships) { String type = relationship.getRelationshipType(); List<Target> targets = relationship.getRelationshipTarget(); visitRelationships(type, targets, true); } } super.visitBase(artifact); }
if (relationship != null && relationship.getOtherAttributes().containsKey(SwitchYardXmlDeriver.UNRESOLVED_REF)) { String ref = relationship.getOtherAttributes().remove(SwitchYardXmlDeriver.UNRESOLVED_REF); if (ref.startsWith("class:")) { //$NON-NLS-1$ String refClassName = ref.substring(6); Target target = new Target(); target.setValue(artifactRef.getUuid()); relationship.getRelationshipTarget().add(target); if (relationship != null && relationship.getOtherAttributes().containsKey(SwitchYardXmlDeriver.UNRESOLVED_REF)) { String ref = relationship.getOtherAttributes().remove(SwitchYardXmlDeriver.UNRESOLVED_REF); if (ref.startsWith("java:")) { //$NON-NLS-1$ String refInterfaceName = ref.substring(5); Target target = new Target(); target.setValue(artifactRef.getUuid()); relationship.getRelationshipTarget().add(target); Target target = new Target(); target.setValue(artifactRef.getUuid()); relationship.getRelationshipTarget().add(target);
relationshipNames.add(relationship.getRelationshipType());
String ifaceName = iface.getAttribute("interface"); //$NON-NLS-1$ Relationship relationship = SrampModelUtils.addGenericRelationship(serviceArtifact, SwitchYardModel.REL_IMPLEMENTS, null); relationship.getOtherAttributes().put(UNRESOLVED_REF, "java:" + ifaceName); //$NON-NLS-1$ String wsdlInfo = iface.getAttribute("interface"); //$NON-NLS-1$ Relationship relationship = SrampModelUtils.addGenericRelationship(serviceArtifact, SwitchYardModel.REL_IMPLEMENTS, null); relationship.getOtherAttributes().put(UNRESOLVED_REF, "wsdl:" + wsdlInfo); //$NON-NLS-1$
private void visitGenericRelationships(BaseArtifactType srampArtifact) throws Exception { for (ArtificerRelationship artificerRelationship : artificerArtifact.getRelationships()) { if (artificerRelationship.getType() == RelationshipType.GENERIC) { Relationship srampRelationship = new Relationship(); srampRelationship.setRelationshipType(artificerRelationship.getName()); for (ArtificerTarget artificerTarget : artificerRelationship.getTargets()) { Target srampTarget = createTarget(Target.class, artificerTarget); srampRelationship.getRelationshipTarget().add(srampTarget); } setOtherAttributes(artificerRelationship.getOtherAttributes(), srampRelationship.getOtherAttributes()); srampArtifact.getRelationship().add(srampRelationship); } } }