use of com.axelor.apps.base.db.DataConfigLine in project axelor-open-suite by axelor.
the class ObjectDataAnonymizeServiceImpl method anonymize.
public void anonymize(ObjectDataConfig objectDataConfig, Long recordId) throws AxelorException {
try {
String rootModel = objectDataConfig.getModelSelect();
for (DataConfigLine line : objectDataConfig.getDataConfigLineList()) {
String path = line.getTypeSelect() == DataConfigLineRepository.TYPE_PATH ? line.getMetaFieldPath().getName() : line.getPath();
Class<? extends Model> modelClass = ObjectDataCommonService.findModelClass(line.getMetaModel());
Query<? extends Model> query = ObjectDataCommonService.createQuery(recordId, line, modelClass);
List<? extends Model> data = query.fetch();
Mapper mapper = Mapper.of(modelClass);
int reset = line.getResetPathSelect();
if (reset != DataConfigLineRepository.RESET_NONE && line.getTypeSelect() == DataConfigLineRepository.TYPE_PATH) {
if (reset == DataConfigLineRepository.RESET_DELETE) {
deleteLink(mapper, path, data);
} else {
replaceLink(mapper, path, data, rootModel, line.getRecordSelectId());
}
}
deleteFields(line.getToDeleteMetaFieldSet(), mapper, data);
}
} catch (Exception e) {
TraceBackService.trace(e);
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, e.getMessage());
}
}
use of com.axelor.apps.base.db.DataConfigLine in project axelor-open-suite by axelor.
the class ObjectDataExportServiceImpl method createData.
private Map<String, List<String[]>> createData(ObjectDataConfig objectDataConfig, Long recordId, String language) throws ClassNotFoundException {
Map<String, List<String[]>> data = new HashMap<>();
for (DataConfigLine line : objectDataConfig.getDataConfigLineList()) {
MetaModel metaModel = line.getMetaModel();
logger.debug("Create data for: {}", metaModel.getName());
Class<? extends Model> modelClass = ObjectDataCommonService.findModelClass(metaModel);
Query<? extends Model> query = ObjectDataCommonService.createQuery(recordId, line, modelClass);
ResourceBundle bundle = ObjectDataCommonService.getResourceBundle(language);
String[][] fieldsData = createFieldsData(line.getToExportMetaFieldSet(), bundle);
Map<String, String> selectMap = getSelectMap(Mapper.of(modelClass));
List<String[]> dataList = fetchData(fieldsData, query, selectMap, bundle);
data.put(line.getTabName(), dataList);
}
return data;
}
Aggregations