use of org.eclipse.winery.model.tosca.TInstanceState in project winery by eclipse.
the class TestWithGitBackedRepository method makeSomeChanges.
protected void makeSomeChanges(NodeTypeId id) throws Exception {
IRepository repo = RepositoryFactory.getRepository();
TNodeType element = repo.getElement(id);
List<TInstanceState> instanceState = new ArrayList<>();
instanceState.add(new TInstanceState("mySuperExtraStateWhichNobodyWouldHaveGuessed"));
element.setInstanceStates(instanceState);
BackendUtils.persist(repo, id, element);
}
use of org.eclipse.winery.model.tosca.TInstanceState in project winery by eclipse.
the class InstanceStatesResource method addInstanceState.
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response addInstanceState(InstanceStateApiData json) {
String state = json.state;
if (StringUtils.isEmpty(state)) {
return Response.notAcceptable(null).build();
}
if (this.instanceStates.removeIf(instanceState -> instanceState.getState().equals(state))) {
// This state is already defined, just return
return Response.noContent().build();
}
instanceStates.add(new TInstanceState(state));
return RestUtils.persist(this.typeResource);
}
use of org.eclipse.winery.model.tosca.TInstanceState in project winery by eclipse.
the class InstanceStatesResource method getInstanceStates.
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<InstanceStateApiData> getInstanceStates() {
List<TInstanceState> instanceStates = this.instanceStates;
ArrayList<InstanceStateApiData> states = new ArrayList<>(instanceStates.size());
for (TInstanceState instanceState : instanceStates) {
states.add(new InstanceStateApiData(instanceState.getState()));
}
return states;
}
Aggregations