public void relationshipInstanceToKmf(RelationshipInstance ri) { checkNull(ri, "Cannot convert null"); net.cloudml.core.RelationshipInstance kb = factory.createRelationshipInstance(); kb.setName(ri.getName()); checkValidPortInstance(ri.getRequiredEnd()); kb.setRequiredPortInstance(requiredPortInstances.get(escapePortInstanceName(ri.getRequiredEnd()))); checkValidPortInstance(ri.getProvidedEnd()); kb.setProvidedPortInstance(providedPortInstances.get(escapePortInstanceName(ri.getProvidedEnd()))); kb.setType(relationships.get(ri.getType().getName())); kDeploy.addRelationshipInstances(kb); }
protected void manageDuplicatedRelationships(RelationshipInstanceGroup rig, Set<ComponentInstance> listOfAllComponentImpacted){ if(rig != null){ dep.configureWithRelationships(rig); for(RelationshipInstance ri: rig){ listOfAllComponentImpacted.add(ri.getClientComponent()); listOfAllComponentImpacted.add(ri.getServerComponent()); } } }
public RelationshipInstance(String name, RequiredPortInstance requiredEnd, ProvidedPortInstance providedEnd, Relationship type) { super(name); this.owner = new OptionalOwner<Deployment>(); setRequiredEnd(requiredEnd); setProvidedEnd(providedEnd); setType(type); }
@Override public boolean equals(Object other) { if (other instanceof RelationshipInstance) { RelationshipInstance otherBinding = (RelationshipInstance) other; return ( ((requiredEnd == null && otherBinding.getRequiredEnd() == null) || requiredEnd.equals(otherBinding.getRequiredEnd())) && ((providedEnd == null && otherBinding.getProvidedEnd() == null) || providedEnd.equals(otherBinding.getProvidedEnd())) ); } else { return false; } } }
HashMap<String,RelationshipInstanceBuilder> rib=new HashMap<String,RelationshipInstanceBuilder>(); for(RelationshipInstance ri: target.getRelationshipInstances()){ final String name = getLibrary().createUniqueRelationshipInstanceName(target, ri.getType()); RelationshipInstance relationship=null; if(mapping.containsKey(ri.getClientComponent())){ if(mapping.containsKey(ri.getServerComponent())){ //TODO: move this in a method rib.put(name,aRelationshipInstance() .named(name) .from(mapping.get(ri.getClientComponent()).getName(), mapping.get(ri.getClientComponent()).asInternal().getRequiredPorts().ofType(ri.getRequiredEnd().getType()).getType().getName()) .to(mapping.get(ri.getServerComponent()).getName(), mapping.get(ri.getServerComponent()).getProvidedPorts().ofType(ri.getProvidedEnd().getType()).getType().getName()) .ofType(ri.getType().getName())); }else{ rib.put(name, aRelationshipInstance() .named(name) .from(mapping.get(ri.getClientComponent()).getName(), mapping.get(ri.getClientComponent()).asInternal().getRequiredPorts().ofType(ri.getRequiredEnd().getType()).getType().getName()) .to(ri.getServerComponent().getName(), ri.getProvidedEnd().getType().getName()) .ofType(ri.getType().getName())); }else if(mapping.containsKey(ri.getServerComponent())){ rib.put(name, aRelationshipInstance() .named(name) .from(ri.getClientComponent().getName(), ri.getRequiredEnd().getName()) .to(mapping.get(ri.getServerComponent()).getName(), mapping.get(ri.getServerComponent()).getProvidedPorts().ofType(ri.getProvidedEnd().getType()).getType().getName())
private void unconfigureRelationship(RelationshipInstance b) { if (!b.getRequiredEnd().getType().isLocal()) { RequiredPortInstance client = b.getRequiredEnd(); ProvidedPortInstance server = b.getProvidedEnd(); Resource clientResource = b.getType().getClientResource(); Resource serverResource = b.getType().getServerResource(); //client resources unconfigureWithIP(clientResource, client); //server resources unconfigureWithIP(serverResource, server); } }
private void addRelationships() { addedRelationships = new ArrayList<RelationshipInstance>(targetDM.getRelationshipInstances()); addedRelationships.removeAll(matchingRelationships.values()); for (RelationshipInstance ni : addedRelationships) { int i = currentDM.getComponentInstances().toList().indexOf(ni.getRequiredEnd().getOwner().get()); if (i >= 0) { ComponentInstance a = currentDM.getComponentInstances().toList().get(i); if (a.isInternal()) { int j = ((InternalComponentInstance) a).getRequiredPorts().toList().indexOf(ni.getRequiredEnd()); ni.setRequiredEnd(((InternalComponentInstance) a).getRequiredPorts().toList().get(j)); } } i = currentDM.getComponentInstances().toList().indexOf(ni.getProvidedEnd().getOwner().get()); if (i >= 0) { ComponentInstance a = currentDM.getComponentInstances().toList().get(i); int j = a.getProvidedPorts().toList().indexOf(ni.getProvidedEnd()); List<ProvidedPortInstance> l = a.getProvidedPorts().toList(); ni.setProvidedEnd(l.get(j)); } } }
public void drawEdgesFromDeploymentModel(Deployment dm, ArrayList<Vertex> v) { for (ComponentInstance x : dm.getComponentInstances()) { if (x instanceof InternalComponentInstance) { InternalComponentInstance ix = (InternalComponentInstance) x; if (ix.getRequiredExecutionPlatform() != null) { Vertex v1 = findVertex(ix.getName(), v); Vertex v2 = findVertex(ix.getRequiredExecutionPlatform().getName(), v); Edge e = new Edge("dest" + ix.getName(), "destination"); createEdge(e, v1, v2); } }//TODO else } for (RelationshipInstance bi : dm.getRelationshipInstances()) { Vertex v1 = findVertex(bi.getRequiredEnd().getOwner().getName(), v); Vertex v2 = findVertex(bi.getProvidedEnd().getOwner().getName(), v); Edge e; if (!bi.getRequiredEnd().getType().isMandatory()) { e = new Edge(bi.getName(), "optional", bi); } else { e = new Edge(bi.getName(), "mandatory", bi); } createEdge(e, v1, v2); } }
public WarXmlConfigValet(RelationshipInstance relationshipInstance, Resource configResource){ this.relationshipInstance = relationshipInstance; this.warCompInst = relationshipInstance.getRequiredEnd().getOwner().get(); this.configResource = configResource; }
if (bi.getRequiredEnd().getType().isMandatory() && x.getRequiredPorts().contains(bi.getRequiredEnd())) { final ComponentInstance<? extends Component> serverComponent = bi.getServerComponent(); if( getDestination(serverComponent).isVM()){ VMInstance owner = (VMInstance) getDestination(serverComponent);
public String selectClientPortInstance(RelationshipInstance bi) { JPanel panel = new JPanel(); panel.add(new JLabel("Please make a selection:")); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (ComponentInstance ai : dm.getComponentInstances()) { if (ai instanceof InternalComponentInstance) { for (RequiredPortInstance ci : ((InternalComponentInstance) ai).getRequiredPorts()) { System.out.println(bi.getType().getRequiredEnd() + " #### " + ci.getType()); if (ci.getType().equals(bi.getType().getRequiredEnd())) { model.addElement(ci); } } } } JComboBox comboBox = new JComboBox(model); panel.add(comboBox); int result = JOptionPane.showConfirmDialog(null, panel, "RequiredPort", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (result) { case JOptionPane.OK_OPTION: bi.setRequiredEnd((RequiredPortInstance) comboBox.getSelectedItem()); return ((RequiredPortInstance) comboBox.getSelectedItem()).getOwner().getName(); } return ""; }
public String selectServerPortInstance(RelationshipInstance bi) { JPanel panel = new JPanel(); panel.add(new JLabel("Please make a selection:")); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (ComponentInstance ai : dm.getComponentInstances()) { Iterator<ProvidedPortInstance> it = ai.getProvidedPorts().iterator(); while (it.hasNext()) {//TODO: check issue with foreach on list<ProvidedPortInstances> ProvidedPortInstance ci = it.next(); if (ci.getType().equals(bi.getType().getProvidedEnd())) { model.addElement(ci); } } } JComboBox comboBox = new JComboBox(model); panel.add(comboBox); int result = JOptionPane.showConfirmDialog(null, panel, "ProvidedPort", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (result) { case JOptionPane.OK_OPTION: bi.setProvidedEnd((ProvidedPortInstance) comboBox.getSelectedItem()); return ((ProvidedPortInstance) comboBox.getSelectedItem()).getOwner().getName(); } return ""; } }
private String relationshipFormating(RelationshipInstance subject) { return "label=\"" + subject.getName() + "\""; }
public ComponentInstance<? extends Component> getServerComponent() { return getProvidedEnd().getOwner().get(); }
public InternalComponentInstanceGroup clientsOf(ComponentInstance<? extends Component> server) { final InternalComponentInstanceGroup selection = new InternalComponentInstanceGroup(); for (RelationshipInstance relationship: this) { if (relationship.isProvidedBy(server)) { selection.add(relationship.getClientComponent()); } } return selection; } }
public RelationshipInstanceGroup ofType(String name) { final RelationshipInstanceGroup selection = new RelationshipInstanceGroup(); for (RelationshipInstance instance: this) { if (instance.getType().isNamed(name)) { selection.add(instance); } } return selection; }
public boolean isProvidedBy(ComponentInstance<? extends Component> candidateServer) { return getServerComponent().equals(candidateServer); }
public boolean isRequiredBy(ComponentInstance<? extends Component> candidateClient) { return getClientComponent().equals(candidateClient); }
@Override public RelationshipInstance build() { final RelationshipInstance relationship = new RelationshipInstance(getName(), createClientPort(), createServerPort(), createType()); super.prepare(relationship); return relationship; }