public SimpleModelRepo(){ root = new Deployment(); }
private Deployment cloneCurrentModel(){ //need to clone the model JsonCodec jsonCodec=new JsonCodec(); ByteArrayOutputStream baos=new ByteArrayOutputStream(); jsonCodec.save(currentModel,baos); Deployment targetModel=new Deployment(); try { String aString = new String(baos.toByteArray(),"UTF-8"); InputStream is = new StringInputStream(aString); targetModel = (Deployment) jsonCodec.load(is); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return targetModel; }
/** * Read a file and build the related model selecting the appropriate codec * based on the file extension. * * @param pathToFile the path to the file * @return the related Deployment object * @throws FileNotFoundException if the given path is invalid */ public Deployment load(String pathToFile) throws FileNotFoundException { failIfNotValid(pathToFile); final Codec codec = getCodec(Utils.getFileExtension(pathToFile)); Deployment model = (Deployment) codec.load(new FileInputStream(pathToFile)); if (model == null) { model = new Deployment(); } return model; }
/** * @param args */ public static void main(String[] args) { Deployment model=new Deployment(); DrawnIconVertexDemo g = new DrawnIconVertexDemo(model); Visu gui= new Visu(model,g); gui.createFrame(); ArrayList<Vertex> v = g.drawVerticesFromDeploymentModel(model); g.drawEdgesFromDeploymentModel(model, v); }
@Override public Deployment build() { Deployment model = new Deployment(getName()); super.prepare(model); for(ProviderBuilder provider: providers) { model.getProviders().add(provider.build()); } for (ComponentBuilder<? extends Component, ? extends ComponentBuilder<?, ?>> builder : components) { builder.integrateIn(model); } for(ComponentInstanceBuilder<? extends ComponentInstance<? extends Component>, ? extends ComponentInstanceBuilder<?,?>> builder: componentInstances) { builder.integrateIn(model); } for (RelationshipBuilder relationship: relationships) { relationship.integrateIn(model); } for (RelationshipInstanceBuilder builder: relationshipInstances) { builder.integrateIn(model); } return model; }
public Deployment clone(){ Deployment tmp=new Deployment(); tmp.getComponents().addAll(this.getComponents()); tmp.getComponentInstances().addAll(this.getComponentInstances()); tmp.getExecuteInstances().addAll(this.getExecuteInstances()); tmp.getProviders().addAll(this.getProviders()); tmp.getRelationshipInstances().addAll(this.getRelationshipInstances()); tmp.getClouds().addAll(this.getClouds()); tmp.getRelationships().addAll(this.getRelationships()); tmp.setName(this.getName()); return tmp; }