Search in sources :

Example 1 with TInstanceState

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);
}
Also used : ArrayList(java.util.ArrayList) IRepository(org.eclipse.winery.repository.backend.IRepository) TInstanceState(org.eclipse.winery.model.tosca.TInstanceState) TNodeType(org.eclipse.winery.model.tosca.TNodeType)

Example 2 with TInstanceState

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);
}
Also used : TInstanceState(org.eclipse.winery.model.tosca.TInstanceState) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 3 with TInstanceState

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;
}
Also used : ArrayList(java.util.ArrayList) InstanceStateApiData(org.eclipse.winery.repository.rest.resources.apiData.InstanceStateApiData) TInstanceState(org.eclipse.winery.model.tosca.TInstanceState) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

TInstanceState (org.eclipse.winery.model.tosca.TInstanceState)3 ArrayList (java.util.ArrayList)2 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 Produces (javax.ws.rs.Produces)1 TNodeType (org.eclipse.winery.model.tosca.TNodeType)1 IRepository (org.eclipse.winery.repository.backend.IRepository)1 InstanceStateApiData (org.eclipse.winery.repository.rest.resources.apiData.InstanceStateApiData)1