Skip to content

Commit

Permalink
Add:
Browse files Browse the repository at this point in the history
- Column Width
- Fixed Width
- Color
- Font
  • Loading branch information
yamelsenih committed Aug 23, 2024
1 parent 6b26797 commit 68d938a
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 4 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ dependencies {

// ADempiere Projects with additional features
// ADempiere gRPC Utils Base (https://central.sonatype.com/artifact/io.github.adempiere/adempiere-grpc-utils)
implementation "${baseGroupId}:adempiere-grpc-utils:1.3.9"
implementation "${baseGroupId}:adempiere-grpc-utils:1.4.8"
// AWS3 Connector to use as File Storagee (https://central.sonatype.com/artifact/io.github.adempiere/adempiere-s3-connector)
implementation "${baseGroupId}:adempiere-s3-connector:1.0.1"
implementation "${baseGroupId}:adempiere-s3-connector:1.0.4"

// Others
compileOnly 'org.apache.tomcat:annotations-api:6.0.53'
Expand Down
61 changes: 61 additions & 0 deletions docker-compose/docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,65 @@ services:
- ${ENVOY_GRPC_PROXY_EXTERNAL_PORT}:${ENVOY_GRPC_PROXY_INTERNAL_PORT}
networks:
- shared_network

# S3 Storage used to export formats
s3.storage:
image: ${S3_IMAGE}
container_name: ${S3_HOST}
restart: ${GENERIC_RESTART}
command:
- "server"
- "/data"
- "--console-address=:${S3_CONSOLE_INTERNAL_PORT}"
healthcheck:
test: "bash -c 'printf \"GET / HTTP/1.1\n\n\" > /dev/tcp/127.0.0.1/9000; exit $?;'"
interval: 10s
retries: 60
start_period: 20s
timeout: 10s
environment:
MINIO_ROOT_USER: ${S3_USER}
MINIO_ROOT_PASSWORD: ${S3_PASSWORD}
ports:
- ${S3_PORT}:9000
- ${S3_CONSOLE_PORT}:${S3_CONSOLE_INTERNAL_PORT}
volumes:
- volume_s3:/data
networks:
- shared_network

s3.client:
image: ${S3_CLIENT_IMAGE}
container_name: ${S3_CLIENT_HOST}
depends_on:
s3.storage:
condition: service_healthy
entrypoint: >
/bin/sh -c "
/usr/bin/mc alias set s3_minio_server http://s3.storage:9000 ${S3_CLIENT_ACCESS_KEY} ${S3_CLIENT_SECRET_KEY};
/usr/bin/mc mb s3_minio_server/${S3_CLIENT_BUCKET_NAME} || true;
exit 0;
"
networks:
- shared_network

s3.gateway.rs:
image: ${S3_GATEWAY_RS_IMAGE}
container_name: ${S3_GATEWAY_RS_HOST}
restart: ${GENERIC_RESTART}
depends_on:
s3.storage:
condition: service_healthy
environment:
S3_URL: ${S3_GATEWAY_RS_S3_URL}
API_KEY: ${S3_GATEWAY_RS_API_KEY}
SECRET_KEY: ${S3_GATEWAY_RS_SECRET_KEY}
BUCKET_NAME: ${S3_GATEWAY_RS_BUCKET_NAME}
MANAGE_HTTPS: ${S3_GATEWAY_RS_MANAGE_HTTPS}
ports:
- ${S3_GATEWAY_RS_PORT}:7878
networks:
- shared_network

networks:
shared_network:
Expand All @@ -69,3 +128,5 @@ networks:
volumes:
volume_postgres:
name: ${POSTGRES_VOLUME}
volume_s3:
name: ${S3_VOLUME}
Binary file not shown.
29 changes: 29 additions & 0 deletions src/main/java/org/spin/report_engine/data/ColumnInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public class ColumnInfo {
private int displayTypeId;
private int sequence;
private boolean isGroupColumn;
private int columnWidth;
private int columnCharactersSize;
private boolean isFixedWidth;
private String fontCode;

private ColumnInfo(PrintFormatItem item) {
this.title = item.getPrintText();
Expand All @@ -41,12 +45,37 @@ private ColumnInfo(PrintFormatItem item) {
this.displayTypeId = item.getReferenceId();
this.sequence = item.getSequence();
this.isGroupColumn = item.isGroupBy();
this.columnWidth = item.getColumnWidth();
this.isFixedWidth = item.isFixedWidth();
this.fontCode = item.getFontCode();
this.color = item.getColor();
}

public static ColumnInfo newInstance(PrintFormatItem item) {
return new ColumnInfo(item);
}

public int getColumnCharactersSize() {
return columnCharactersSize;
}

public ColumnInfo withColumnCharactersSize(int columnCharactersSize) {
this.columnCharactersSize = columnCharactersSize;
return this;
}

public int getColumnWidth() {
return columnWidth;
}

public boolean isFixedWidth() {
return isFixedWidth;
}

public String getFontCode() {
return fontCode;
}

public int getDisplayTypeId() {
return displayTypeId;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/spin/report_engine/data/ReportInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ private Comparator<Row> getSortingValue(boolean summaryAtEnd) {
return comparator.get();
}

public PrintFormat getPrintFormat() {
return printFormat;
}

public ReportInfo completeInfo() {
groupedRows = summaryHandler.getAsRows();
List<Row> completeRows = Stream.concat(getRows().stream(), groupedRows.stream())
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/org/spin/report_engine/format/PrintFormatItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
package org.spin.report_engine.format;

import org.adempiere.core.domains.models.I_AD_PrintFormatItem;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.MColumn;
import org.compiere.print.MPrintColor;
import org.compiere.print.MPrintFont;
import org.compiere.print.MPrintFormatItem;
import org.compiere.util.DisplayType;
import org.compiere.util.Util;
Expand Down Expand Up @@ -62,6 +65,10 @@ public class PrintFormatItem {
private boolean isVirtualColumn;
private String columnSql;
private String mappingClassName;
private int columnWidth;
private boolean isFixedWidth;
private String fontCode;
private String color;


/** PrintFormatType AD_Reference_ID=255 */
Expand Down Expand Up @@ -176,6 +183,29 @@ private PrintFormatItem(MPrintFormatItem printFormatItem) {
formatPattern = printFormatItem.getFormatPattern();
}
mappingClassName = printFormatItem.get_ValueAsString("MappingClassName");
columnWidth = printFormatItem.getMaxWidth();
isFixedWidth = printFormatItem.isFixedWidth();
if(printFormatItem.getAD_PrintFont_ID() > 0) {
MPrintFont printFont = MPrintFont.get(printFormatItem.getAD_PrintFont_ID());
if(printFont != null) {
fontCode = printFont.getCode();
}
}
if(printFormatItem.getAD_PrintColor_ID() > 0) {
MPrintColor printColor = MPrintColor.get(printFormatItem.getCtx(), printFormatItem.getAD_PrintColor_ID());
String colorCode = printColor.getCode();
if(!Util.isEmpty(colorCode)) {
try {
if(colorCode.equals(".")) {
colorCode = "0";
}
int rgbColor = Integer.parseInt(colorCode);
color = String.format("#%06x", rgbColor & 0x00ffffff);
} catch (Exception e) {
throw new AdempiereException(e);
}
}
}
}

public static PrintFormatItem newInstance(MPrintFormatItem printFormatItem) {
Expand All @@ -191,6 +221,22 @@ public PrintFormatItem withMappingClassName(String mappingClassName) {
return this;
}

public int getColumnWidth() {
return columnWidth;
}

public boolean isFixedWidth() {
return isFixedWidth;
}

public String getFontCode() {
return fontCode;
}

public String getColor() {
return color;
}

public String getName() {
return name;
}
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/org/spin/report_engine/format/QueryDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class QueryDefinition {
private List<PrintFormatColumn> queryColumns;
private String whereClause;
private String completeQuery;
private String completeQueryCount;
private int limit;
private int offset;
private int instanceId;
Expand Down Expand Up @@ -141,6 +142,15 @@ public String getCompleteQuery() {
return completeQuery;
}

public String getCompleteQueryCount() {
return completeQueryCount;
}

public QueryDefinition withCompleteQueryCount(String completeQueryCount) {
this.completeQueryCount = completeQueryCount;
return this;
}

public QueryDefinition withCompleteQuery(String completeQuery) {
this.completeQuery = completeQuery;
return this;
Expand All @@ -167,6 +177,18 @@ public QueryDefinition buildQuery() {
whereClause.append(restriction);
}
});
// No Limit for Counter
StringBuffer completeQueryWithoutLimit = new StringBuffer(getQuery());
if(!Util.isEmpty(getWhereClause())) {
completeQueryWithoutLimit.append(" WHERE ").append(whereClause);
}
if(!Util.isEmpty(getGroupBy())) {
completeQueryWithoutLimit.append(" GROUP BY ").append(getGroupBy());
}
if(!Util.isEmpty(getOrderBy())) {
completeQueryWithoutLimit.append(" ORDER BY ").append(getOrderBy());
}
withCompleteQueryCount(completeQueryWithoutLimit.toString());
// Add Limit
if(limit != NO_LIMIT) {
if(limit == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private ReportInfo get(String transactionName) {
MPrintFormat printFormat = new MPrintFormat(Env.getCtx(), getPrintFormatId(), null);
PrintFormat format = PrintFormat.newInstance(printFormat);
QueryDefinition queryDefinition = format.getQuery().withConditions(conditions).withInstanceId(getInstanceId()).withLimit(limit, offset).buildQuery();
int count = CountUtil.countRecords(queryDefinition.getCompleteQuery(), format.getTableName(), queryDefinition.getParameters());
int count = CountUtil.countRecords(queryDefinition.getCompleteQueryCount(), format.getTableName(), queryDefinition.getParameters());
ReportInfo reportInfo = ReportInfo.newInstance(format, queryDefinition).withReportViewId(getReportViewId()).withInstanceId(getInstanceId()).withRecordCount(count);
DB.runResultSet(transactionName, queryDefinition.getCompleteQuery(), queryDefinition.getParameters(), resulset -> {
while (resulset.next()) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/spin/report_engine/service/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ private static Report.Builder convertReport(ReportInfo reportInfo, int limit, in
.setTitle(ValueManager.validateNull(column.getTitle()))
.setColor(ValueManager.validateNull(column.getColor()))
.setStyle(ValueManager.validateNull(column.getStyle()))
.setFontCode(ValueManager.validateNull(column.getFontCode()))
.setIsFixedWidth(column.isFixedWidth())
.setColumnWidth(column.getColumnWidth())
.setColumnCharactersSize(column.getColumnCharactersSize())
.setDisplayType(column.getDisplayTypeId())
.setIsGroupColumn(column.isGroupColumn())
.setSequence(column.getSequence())
Expand Down
6 changes: 5 additions & 1 deletion src/main/proto/service/report_engine.proto
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,15 @@ message Report {
message ReportColumn {
string code = 1;
string title = 2;
string color= 3;
string color = 3;
string style = 4;
int32 display_type = 5;
bool is_group_column = 6;
int32 sequence = 7;
int32 column_width = 8;
int32 column_characters_size = 9;
bool is_fixed_width = 10;
string font_code = 11;
}

message ReportRow {
Expand Down

0 comments on commit 68d938a

Please sign in to comment.