use of org.eclipse.winery.repository.rest.resources._support.dataadapter.injectionadapter.InjectorReplaceOptions in project winery by eclipse.
the class ServiceTemplateResource method getInjectorOptions.
@GET
@Path("injector/options")
@Produces({ MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.APPLICATION_JSON })
public Response getInjectorOptions() {
Splitting splitting = new Splitting();
TTopologyTemplate topologyTemplate = this.getServiceTemplate().getTopologyTemplate();
Map<String, List<TTopologyTemplate>> hostMatchingOptions;
Map<String, List<TTopologyTemplate>> connectionMatchingOptions;
InjectorReplaceOptions injectionReplaceOptions = new InjectorReplaceOptions();
try {
Map<TRequirement, String> requirementsAndMatchingBasisCapabilityTypes = splitting.getOpenRequirementsAndMatchingBasisCapabilityTypeNames(this.getServiceTemplate().getTopologyTemplate());
// Output check
for (TRequirement req : requirementsAndMatchingBasisCapabilityTypes.keySet()) {
System.out.println("open Requirement: " + req.getId());
System.out.println("matchingBasisType: " + requirementsAndMatchingBasisCapabilityTypes.get(req));
}
if (requirementsAndMatchingBasisCapabilityTypes.containsValue("Container")) {
hostMatchingOptions = splitting.getHostingMatchingOptionsWithDefaultLabeling(topologyTemplate);
} else {
hostMatchingOptions = null;
}
if (requirementsAndMatchingBasisCapabilityTypes.containsValue("Endpoint")) {
connectionMatchingOptions = splitting.getConnectionInjectionOptions(topologyTemplate);
} else {
connectionMatchingOptions = null;
}
injectionReplaceOptions.setTopologyTemplate(topologyTemplate);
injectionReplaceOptions.setHostInjectionOptions(hostMatchingOptions);
injectionReplaceOptions.setConnectionInjectionOptions(connectionMatchingOptions);
if (hostMatchingOptions == null && connectionMatchingOptions == null) {
return Response.status(Status.BAD_REQUEST).type(MediaType.TEXT_PLAIN).entity("No need for matching").build();
}
} catch (SplittingException e) {
LOGGER.error("Could not match", e);
return Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build();
}
return Response.ok().entity(injectionReplaceOptions).build();
}
Aggregations