/** * Prints out a single relationship. * @param name * @param target */ private void printRelationship(String name, Target target) { String targetStr = target.getValue(); printProperty(name, targetStr); }
private void createTarget(ArtificerRelationship artificerRelationship, Target target) throws Exception { ArtificerTarget artificerTarget = new ArtificerTarget(); artificerTarget.setTarget(relationshipFactory.createRelationship(target.getValue(), entityManager)); // Use reflection to get the 'artifact type' enum attribute found on // most (all?) targets. Unfortunately, the method and field are // redefined in each subclass of Target. // Get ^^^ changed in the spec! try { Method m = target.getClass().getMethod("getArtifactType"); Object o = m.invoke(target); // the enum itself m = o.getClass().getMethod("name"); String targetType = (String) m.invoke(o); artificerTarget.setTargetType(targetType); } catch (Exception e) { // eat it } artificerTarget.setRelationship(artificerRelationship); for (QName key : target.getOtherAttributes().keySet()) { String value = target.getOtherAttributes().get(key); artificerTarget.getOtherAttributes().put(key.toString(), value); } artificerRelationship.getTargets().add(artificerTarget); } }
Target target = new Target(); target.setValue(targetUUID); target.getOtherAttributes().putAll(targetOtherAttributes); relationship.getRelationshipTarget().add(target);
private <T> T createTarget(Class<T> targetClass, ArtificerTarget artificerTarget) throws Exception { T t = targetClass.newInstance(); Target target = (Target) t; if (artificerTarget != null) { String targetedUuid = artificerTarget.getTarget().getUuid(); target.setValue(targetedUuid); String href = String.format("%1$s/%2$s/%3$s", artificerTarget.getTarget().getModel(), artificerTarget.getTarget().getType(), targetedUuid); target.setHref(href); setOtherAttributes(artificerTarget.getOtherAttributes(), target.getOtherAttributes()); } return t; } }
/** * Create an instance of {@link Target } * */ public Target createTarget() { return new Target(); }
T t = targetClass.newInstance(); Target target = (Target) t; target.setValue(referenceResolver.resolveReference(value));
Target relationshipTarget = new Target(); relationshipTarget.setValue("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaa6b"); relationshipTarget.getOtherAttributes().put( new QName("xlink:href"), "http://example.org/s-ramp/xsd/XsdDocument/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaa6b"); relationship.getRelationshipTarget().add(relationshipTarget); Target relationshipTarget2 = new Target(); relationshipTarget2.setValue("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaa6c"); relationshipTarget2.getOtherAttributes().put( new QName("xlink:href"), "http://example.org/s-ramp/xsd/XsdDocument/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaa6c");
/** * Create an instance of {@link Target } * */ public Target createTarget() { return new Target(); }
T t = targetClass.newInstance(); Target target = (Target) t; target.setValue(referenceResolver.resolveReference(value));
/** * Prints out a single relationship. * @param name * @param targets */ private void printRelationship(String name, List<? extends Target> targets) { String targetStr = ""; boolean first = true; for (Target target : targets) { if (!first) { targetStr += ", "; } else { first = false; } targetStr += target.getValue(); } printProperty(name, targetStr); }
/** * @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); } } } }
private void setRelationship(String relationshipName, RelationshipType relationshipType, Target target) throws Exception { if (target != null && StringUtils.isNotBlank(target.getValue())) { ArtificerRelationship artificerRelationship = createRelationship(relationshipName, relationshipType, Collections.EMPTY_MAP); createTarget(artificerRelationship, target); artificerArtifact.getRelationships().add(artificerRelationship); } }
/** * @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); } } } }
private void setRelationships(String relationshipName, RelationshipType relationshipType, List<? extends Target> targets, Map<QName, String> relationshipOtherAttributes) throws Exception { if (targets.size() > 0) { ArtificerRelationship artificerRelationship = createRelationship(relationshipName, relationshipType, relationshipOtherAttributes); for (Target target : targets) { if (StringUtils.isNotBlank(target.getValue())) { createTarget(artificerRelationship, target); } } if (!artificerRelationship.getTargets().isEmpty()) { artificerArtifact.getRelationships().add(artificerRelationship); } } }
BaseArtifactType artifactRef = findJavaClassArtifact(refClassName); if (artifactRef != null) { Target target = new Target(); target.setValue(artifactRef.getUuid()); relationship.getRelationshipTarget().add(target); BaseArtifactType artifactRef = findJavaInterfaceArtifact(refInterfaceName); if (artifactRef != null) { Target target = new Target(); target.setValue(artifactRef.getUuid()); relationship.getRelationshipTarget().add(target); BaseArtifactType artifactRef = findWsdlArtifact(refWsdl); if (artifactRef != null) { Target target = new Target(); target.setValue(artifactRef.getUuid()); relationship.getRelationshipTarget().add(target);
/** * Sets a relationship on the given artifact parent node. * @param relationshipType * @param maxCardinality * @param minCardinality * @param targetType * @param isGeneric * @param targets * @throws Exception */ private void setRelationships(String relationshipType, int maxCardinality, int minCardinality, String targetType, boolean isGeneric, List<? extends Target> targets) throws Exception { if (!isProcessRelationships()) return; if ((targets != null && targets.size() > 0) || minCardinality == 0) { Node relationshipNode = getOrCreateRelationshipNode(this.jcrNode, relationshipType, maxCardinality, targetType, isGeneric); Value[] values = new Value[targets.size()]; for (int idx = 0; idx < targets.size(); idx++) { values[idx] = this.referenceFactory.createReference(targets.get(idx).getValue()); } relationshipNode.setProperty("sramp:relationshipTarget", values); //$NON-NLS-1$ } else { // If the minimum cardinality is > 0 but no targets have been provided, then // remove the relationship node. removeRelationship(relationshipType); } }
BaseArtifactType artifactRef = findJavaClassArtifact(refClassName); if (artifactRef != null) { Target target = new Target(); target.setValue(artifactRef.getUuid()); relationship.getRelationshipTarget().add(target); BaseArtifactType artifactRef = findCDIBeanArtifact(refBeanName); if (artifactRef != null) { Target target = new Target(); target.setValue(artifactRef.getUuid()); relationship.getRelationshipTarget().add(target); BaseArtifactType artifactRef = findJavaClassArtifact(refClassName); if (artifactRef != null) { Target target = new Target(); target.setValue(artifactRef.getUuid()); relationship.getRelationshipTarget().add(target); BaseArtifactType artifactRef = findElementDeclarationArtifact(refQName); if (artifactRef != null) { Target target = new Target(); target.setValue(artifactRef.getUuid()); relationship.getRelationshipTarget().add(target);
/** * Sets a relationship on the given artifact parent node. * @param relationshipType * @param maxCardinality * @param minCardinality * @param targetType * @param isGeneric * @param target * @throws Exception */ private void setRelationship(String relationshipType, int maxCardinality, int minCardinality, String targetType, boolean isGeneric, Target target) throws Exception { if (!isProcessRelationships()) return; if (target != null || minCardinality == 0) { Node relationshipNode = getOrCreateRelationshipNode(this.jcrNode, relationshipType, maxCardinality, targetType, isGeneric); Value [] values = new Value[1]; values[0] = this.referenceFactory.createReference(target.getValue()); relationshipNode.setProperty("sramp:relationshipTarget", values); //$NON-NLS-1$ } else { // If the minimum cardinality is > 0 but no targets have been provided, then // remove the relationship node. removeRelationship(relationshipType); } }