use of com.axelor.apps.base.db.FileTab in project axelor-open-suite by axelor.
the class FileTabController method validateActions.
public void validateActions(ActionRequest request, ActionResponse response) {
FileTab fileTab = request.getContext().asType(FileTab.class);
if (StringUtils.isEmpty(fileTab.getActions())) {
return;
}
ActionService actionService = Beans.get(ActionService.class);
if (!actionService.validate(fileTab.getActions())) {
response.setError(String.format(IExceptionMessage.ADVANCED_IMPORT_LOG_10, fileTab.getMetaModel().getName()));
}
}
use of com.axelor.apps.base.db.FileTab in project axelor-open-suite by axelor.
the class FileTabController method compute.
public void compute(ActionRequest request, ActionResponse response) {
try {
FileTab fileTab = request.getContext().asType(FileTab.class);
fileTab = Beans.get(FileTabService.class).compute(fileTab);
response.setValues(fileTab);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.base.db.FileTab in project axelor-open-suite by axelor.
the class FileTabController method validateSearchCall.
public void validateSearchCall(ActionRequest request, ActionResponse response) {
FileTab fileTab = request.getContext().asType(FileTab.class);
SearchCallService searchCallService = Beans.get(SearchCallService.class);
if (!searchCallService.validate(fileTab.getSearchCall())) {
response.setError(String.format(IExceptionMessage.ADVANCED_IMPORT_LOG_11, fileTab.getMetaModel().getName()));
}
}
use of com.axelor.apps.base.db.FileTab in project axelor-open-suite by axelor.
the class FileTabController method updateFields.
public void updateFields(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
Map<String, Object> map = context.getParent();
if (map == null || (boolean) map.get("isConfigInFile") == true) {
return;
}
FileTab fileTab = context.asType(FileTab.class);
Beans.get(FileTabService.class).updateFields(fileTab);
response.setValue("fileFieldList", fileTab.getFileFieldList());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.base.db.FileTab in project axelor-open-suite by axelor.
the class ImportAdvancedImport method importGeneral.
@SuppressWarnings("unchecked")
public Object importGeneral(Object bean, Map<String, Object> values) throws ClassNotFoundException {
if (bean == null) {
return bean;
}
FileTab fileTab = fileTabRepo.find(Long.valueOf(values.get("fileTabId").toString()));
ScriptHelper scriptHelper = new GroovyScriptHelper(new ScriptBindings(values));
List<String> exprs = (List<String>) values.get("ifConditions" + fileTab.getId());
if (!CollectionUtils.isEmpty(exprs)) {
if ((boolean) scriptHelper.eval(String.join(" || ", exprs))) {
return null;
}
}
if (((Model) bean).getId() == null) {
List<Property> propList = this.getProperties(bean);
JPA.save((Model) bean);
this.addJsonObjectRecord(bean, fileTab, fileTab.getMetaModel().getName(), values);
int fieldSeq = 2;
int btnSeq = 3;
for (Property prop : propList) {
validatorService.createCustomObjectSet(fileTab.getClass().getName(), prop.getTarget().getName(), fieldSeq);
validatorService.createCustomButton(fileTab.getClass().getName(), prop.getTarget().getName(), btnSeq);
this.addJsonObjectRecord(prop.get(bean), fileTab, StringUtils.substringAfterLast(prop.getTarget().getName(), "."), values);
fieldSeq++;
btnSeq++;
}
}
final String ACTIONS_TO_APPLY = "actionsToApply" + fileTab.getId();
if (!ObjectUtils.isEmpty(values.get(ACTIONS_TO_APPLY))) {
bean = actionService.apply(values.get(ACTIONS_TO_APPLY).toString(), bean);
}
return bean;
}
Aggregations