use of com.axelor.apps.base.db.AdvancedExportLine in project axelor-open-suite by axelor.
the class AdvancedExportServiceImpl method getAdvancedExportQuery.
/**
* This method split and join the all fields/columns which are selected by user and create the
* query.
*
* @param advancedExport
* @param criteria
* @return
* @throws AxelorException
* @throws ClassNotFoundException
*/
@Override
public Query getAdvancedExportQuery(AdvancedExport advancedExport, List<Long> recordIds) throws AxelorException {
StringBuilder selectFieldBuilder = new StringBuilder();
StringBuilder orderByFieldBuilder = new StringBuilder();
joinFieldSet.clear();
selectionJoinFieldSet.clear();
isNormalField = true;
selectField = "";
msi = 0;
mt = 0;
int col = 0;
language = Optional.ofNullable(AuthUtils.getUser()).map(User::getLanguage).orElse(null);
try {
if (language == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get("Please select a language on user form."));
}
for (AdvancedExportLine advancedExportLine : advancedExport.getAdvancedExportLineList()) {
String[] splitField = advancedExportLine.getTargetField().split("\\.");
String alias = "Col_" + col;
createQueryParts(splitField, 0, advancedExport.getMetaModel());
selectFieldBuilder.append(aliasName + selectField + " AS " + alias + ",");
if (advancedExportLine.getOrderBy()) {
orderByFieldBuilder.append(alias + " " + advancedExportLine.getOrderByType() + ",");
}
selectField = "";
aliasName = "";
col++;
}
if (StringUtils.notEmpty(orderByFieldBuilder)) {
orderByFieldBuilder.append("self.id asc,");
}
} catch (ClassNotFoundException e) {
TraceBackService.trace(e);
throw new AxelorException(e, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR);
}
return createQuery(createQueryBuilder(advancedExport, selectFieldBuilder, recordIds, orderByFieldBuilder));
}
use of com.axelor.apps.base.db.AdvancedExportLine in project axelor-open-suite by axelor.
the class ExcelExportGenerator method generateHeader.
@Override
public void generateHeader() {
Row headerRow = sheet.createRow(sheet.getFirstRowNum());
int colHeaderNum = 0;
for (AdvancedExportLine advancedExportLine : advancedExport.getAdvancedExportLineList()) {
Cell headerCell = headerRow.createCell(colHeaderNum++);
headerCell.setCellValue(I18n.get(advancedExportLine.getTitle()));
}
}
use of com.axelor.apps.base.db.AdvancedExportLine in project axelor-open-suite by axelor.
the class AdvancedExportController method metaFieldDomain.
public void metaFieldDomain(ActionRequest request, ActionResponse response) throws ClassNotFoundException {
AdvancedExportLine adv = request.getContext().asType(AdvancedExportLine.class);
MetaModel metaModel = Beans.get(MetaModelRepository.class).findByName(adv.getCurrentDomain());
List<MetaField> metaFields = metaModel.getMetaFields();
List<Long> metaFieldList = new ArrayList<>();
if (metaFields != null) {
Class<?> klass = Class.forName(metaModel.getFullName());
Mapper mapper = Mapper.of(klass);
for (MetaField field : metaFields) {
if (!mapper.getProperty(field.getName()).isTransient()) {
metaFieldList.add(field.getId());
}
}
}
metaFieldList.add(0L);
response.setAttr("metaField", "domain", "self.id in (" + Joiner.on(",").join(metaFieldList) + ")");
}
use of com.axelor.apps.base.db.AdvancedExportLine in project axelor-open-suite by axelor.
the class CsvExportGenerator method generateHeader.
@Override
public void generateHeader() {
int index = 0;
for (AdvancedExportLine advancedExportLine : advancedExport.getAdvancedExportLineList()) {
totalCols[index++] = I18n.get(advancedExportLine.getTitle());
}
csvWriter.writeNext(totalCols);
}
use of com.axelor.apps.base.db.AdvancedExportLine in project axelor-open-suite by axelor.
the class PdfExportGenerator method generateHeader.
@Override
public void generateHeader() throws AxelorException {
try {
PdfPCell headerCell;
for (AdvancedExportLine advancedExportLine : advancedExport.getAdvancedExportLineList()) {
headerCell = new PdfPCell(new Phrase(I18n.get(advancedExportLine.getTitle()), new Font(BaseFont.createFont(), 8, 0, BaseColor.WHITE)));
headerCell.setBackgroundColor(BaseColor.GRAY);
headerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(headerCell);
}
} catch (DocumentException | IOException e) {
TraceBackService.trace(e);
throw new AxelorException(e, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR);
}
}
Aggregations