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 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 ""; } }
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 ""; }
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); } }
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); }
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())){ .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() .to(ri.getServerComponent().getName(), ri.getProvidedEnd().getType().getName()) .ofType(ri.getType().getName())); .to(mapping.get(ri.getServerComponent()).getName(), mapping.get(ri.getServerComponent()).getProvidedPorts().ofType(ri.getProvidedEnd().getType()).getType().getName()) .ofType(ri.getType().getName()));
ComponentInstance clienti = bi.getRequiredEnd().getOwner().get(); if (serveri.isExternal() && "database".equals(((ExternalComponentInstance<ExternalComponent>) serveri).getType().getServiceType())) { //For DB for (Resource res : bi.getType().getResources()) { ConfigValet valet = ConfigValet.createValet(bi, res); if (valet != null) ProvidedPortInstance server = bi.getProvidedEnd(); Resource clientResource = bi.getType().getClientResource(); ProvidedPortInstance server = bi.getProvidedEnd(); Resource clientResource = bi.getType().getClientResource(); Resource serverResource = bi.getType().getServerResource(); this.bi=bi; retrieveIPandConfigure(serverResource,clientResource,server,client);