use of org.cerberus.crud.service.ILabelService in project cerberus-source by cerberustesting.
the class ReadLabel method findLabelByKey.
private AnswerItem findLabelByKey(Integer id, ApplicationContext appContext, boolean userHasPermissions) throws JSONException, CerberusException {
AnswerItem item = new AnswerItem();
JSONObject object = new JSONObject();
ILabelService labelService = appContext.getBean(ILabelService.class);
// finds the project
AnswerItem answer = labelService.readByKey(id);
if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {
// if the service returns an OK message then we can get the item and convert it to JSONformat
Label label = (Label) answer.getItem();
JSONObject labelObject = convertLabelToJSONObject(label);
if (!"".equals(label.getParentLabel())) {
labelObject.put("labelParentObject", convertLabelToJSONObject((Label) labelService.readByKey(Integer.valueOf(label.getParentLabel())).getItem()));
}
JSONObject response = labelObject;
object.put("contentTable", response);
}
object.put("hasPermissions", userHasPermissions);
item.setItem(object);
item.setResultMessage(answer.getResultMessage());
return item;
}
Aggregations