@Override public String toString() { return "ArtefactPortInstance " + name + " owner:" + owner.getName(); } }
@Override public String toString() { return "ClientPortInstance " + name + " owner:" + owner.getName(); }
@Override public String toString() { return "ServerPortInstance " + name + " owner:" + owner.getName(); }
/** * Search for an artefact instance whose name matches the given id. If no * such instance matches, it returns null. * * @param id the id of the needed instance * @return the instance associated with the given id or null by default. */ private ArtefactInstance findArtefactInstanceById(final String id) { ArtefactInstance result = null; final Iterator<ArtefactInstance> instances = deploy.getArtefactInstances().iterator(); while (result == null && instances.hasNext()) { final ArtefactInstance instance = instances.next(); if (instance.getName().equals(id)) { result = instance; } } return result; }
@Override public boolean equals(Object other) { if (other instanceof ArtefactInstance) { ArtefactInstance otherArt = (ArtefactInstance) other; Boolean match= name.equals(otherArt.getName()) && type.equals(otherArt.getType()); if(destination != null) return name.equals(otherArt.getName()) && type.equals(otherArt.getType()) && destination.equals(otherArt.getDestination()); else return match && (otherArt.getDestination() == null); } else { return false; } }
public String selectServerPortInstance(BindingInstance bi){ JPanel panel = new JPanel(); panel.add(new JLabel("Please make a selection:")); DefaultComboBoxModel model = new DefaultComboBoxModel(); for(ArtefactInstance ai:dm.getArtefactInstances()){ for(ServerPortInstance ci:ai.getProvided()){ if(ci.getType().equals(bi.getType().getServer())){ model.addElement(ci); } } } JComboBox comboBox = new JComboBox(model); panel.add(comboBox); int result = JOptionPane.showConfirmDialog(null, panel, "ServerPort", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (result) { case JOptionPane.OK_OPTION: bi.setServer((ServerPortInstance)comboBox.getSelectedItem()); return ((ServerPortInstance)comboBox.getSelectedItem()).getOwner().getName(); } return ""; }
public ArrayList<Vertex> drawVerticesFromDeploymentModel(DeploymentModel dm){ ArrayList<Vertex> V=new ArrayList<Vertex>(); for(NodeInstance n : dm.getNodeInstances()){ Vertex v= new Vertex(n.getName(), "node",n); V.add(v); createVertice(v); } for(ArtefactInstance x : dm.getArtefactInstances()){ if(x.getDestination() == null){ Vertex v= new Vertex(x.getName(), "platform",x); V.add(v); createVertice(v); }else{ Vertex v= new Vertex(x.getName(), "soft",x); V.add(v); createVertice(v); } properties.setModel(new CPIMTable(V.get(0))); runtimeProperties.setModel(new CPSMTable(V.get(0))); } return V; }
public String selectClientPortInstance(BindingInstance bi){ JPanel panel = new JPanel(); panel.add(new JLabel("Please make a selection:")); DefaultComboBoxModel model = new DefaultComboBoxModel(); for(ArtefactInstance ai:dm.getArtefactInstances()){ System.out.println(ai.getRequired()); for(ClientPortInstance ci:ai.getRequired()){ System.out.println(bi.getType().getClient() + " #### "+ ci.getType()); if(ci.getType().equals(bi.getType().getClient())){ model.addElement(ci); } } } JComboBox comboBox = new JComboBox(model); panel.add(comboBox); int result = JOptionPane.showConfirmDialog(null, panel, "ClientPort", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (result) { case JOptionPane.OK_OPTION: bi.setClient((ClientPortInstance)comboBox.getSelectedItem()); return ((ClientPortInstance)comboBox.getSelectedItem()).getOwner().getName(); } return ""; }
public void drawEdgesFromDeploymentModel(DeploymentModel dm, ArrayList<Vertex> v){ for(ArtefactInstance x : dm.getArtefactInstances()){ if(x.getDestination() != null){ Vertex v1=findVertex(x.getName(), v); Vertex v2=findVertex(x.getDestination().getName(), v); Edge e=new Edge("dest"+x.getName(), "destination"); createEdge(e, v1, v2); } } for(BindingInstance bi: dm.getBindingInstances()){ Vertex v1=findVertex(bi.getClient().getOwner().getName(), v); Vertex v2=findVertex(bi.getServer().getOwner().getName(), v); Edge e; if(bi.getClient().getType().getIsOptional()) e=new Edge(bi.getName(), "optional",bi); else e=new Edge(bi.getName(), "mandatory",bi); createEdge(e, v1, v2); } }
ArtefactInstance ai = new ArtefactInstance(kai.getName(), artefacts.get(kai.getType().getName())); initProperties(kai, ai); artefactInstances.put(ai.getName(), ai);
kai.setName(ai.getName()); kai.setType(artefacts.get(ai.getType().getName())); initProperties(ai, kai, factory);