use of org.eclipse.winery.repository.rest.datatypes.TypeWithShortName in project winery by eclipse.
the class AbstractTypesManager method getTypesAsJSONArrayList.
@GET
@Produces(MediaType.APPLICATION_JSON)
public Object getTypesAsJSONArrayList(@QueryParam("ngSelect") String ngSelect) {
if (ngSelect == null) {
return this.getTypes();
} else {
// ngSelect mode
SortedSet<Select2DataItem> res = new TreeSet<>();
for (TypeWithShortName t : this.getTypes()) {
Select2DataItem item = new Select2DataItem(t.getType(), t.getShortName());
res.add(item);
}
return res;
}
}
use of org.eclipse.winery.repository.rest.datatypes.TypeWithShortName in project winery by eclipse.
the class AbstractTypesManager method addData.
protected void addData(String longName, String shortName) {
TypeWithShortName t = new TypeWithShortName(longName, shortName);
this.addData(t);
}
use of org.eclipse.winery.repository.rest.datatypes.TypeWithShortName in project winery by eclipse.
the class AbstractTypesManager method getShortName.
/**
* <b>SIDEEFFECT:</b> If there currently isn't any short type name, it is
* created
*/
public String getShortName(String typeString) {
TypeWithShortName type = this.hashTypeStringToType.get(typeString);
String res;
if (type == null) {
// happens if artifact type is not registered in artifacttypes.list
// (DATAFILENAME)
res = typeString;
} else {
res = type.getShortName();
}
return res;
}
use of org.eclipse.winery.repository.rest.datatypes.TypeWithShortName in project winery by eclipse.
the class AbstractTypesManager method updateTypeMapping.
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response updateTypeMapping(TypeWithShortNameApiData newType) {
if (StringUtils.isEmpty(newType.shortName)) {
return Response.status(Status.BAD_REQUEST).entity("shortName has to be given").build();
}
if (StringUtils.isEmpty(newType.type)) {
return Response.status(Status.BAD_REQUEST).entity("type has to be given").build();
}
String shortName = Util.URLdecode(newType.shortName);
String type = Util.URLdecode(newType.type);
TypeWithShortName tws = new TypeWithShortName(type, shortName);
this.addTypeWithShortName(tws);
return Response.noContent().build();
}
use of org.eclipse.winery.repository.rest.datatypes.TypeWithShortName in project winery by eclipse.
the class AbstractTypesManager method getTypeWithShortName.
/**
* <b>SIDEEFFECT:</b> If there currently isn't any short type name, it is
* created
*/
public TypeWithShortName getTypeWithShortName(String typeString) {
TypeWithShortName t = this.hashTypeStringToType.get(typeString);
if (t == null) {
String shortName = this.getShortName(typeString);
t = new TypeWithShortName(typeString, shortName);
this.addTypeWithShortName(t);
}
return t;
}
Aggregations