Skip to content

Commit

Permalink
fix: List tables Import File Loader form. (#872)
Browse files Browse the repository at this point in the history
* fix: List tables `Import File Loader` form.

* add uuid on entitnes.

* move classes.

* change package.
  • Loading branch information
EdwinBetanc0urt authored Aug 29, 2024
1 parent 3af6286 commit fe7c421
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 56 deletions.
Binary file modified resources/adempiere-grpc-server.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/java/org/spin/grpc/service/SendNotifications.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
*/
public class SendNotifications extends SendNotificationsImplBase{
/** Logger */
private CLogger log = CLogger.getCLogger(ImportFileLoader.class);
private CLogger log = CLogger.getCLogger(SendNotifications.class);


@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
************************************************************************************/
package org.spin.grpc.service;
package org.spin.grpc.service.form.import_file_loader;

import org.adempiere.exceptions.AdempiereException;
import org.compiere.util.CLogger;
import org.spin.backend.grpc.common.ListEntitiesResponse;
import org.spin.backend.grpc.common.ListLookupItemsResponse;
import org.spin.backend.grpc.form.import_file_loader.GetImportFromatRequest;
import org.spin.backend.grpc.form.import_file_loader.ImportFileLoaderGrpc.ImportFileLoaderImplBase;
import org.spin.form.import_file_loader.ImportFileLoaderServiceLogic;
import org.spin.backend.grpc.form.import_file_loader.ImportFormat;
import org.spin.backend.grpc.form.import_file_loader.ListCharsetsRequest;
import org.spin.backend.grpc.form.import_file_loader.ListFilePreviewRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
************************************************************************************/

package org.spin.form.import_file_loader;
package org.spin.grpc.service.form.import_file_loader;

import org.adempiere.core.domains.models.I_AD_Column;
import org.adempiere.core.domains.models.I_AD_Table;
Expand Down Expand Up @@ -42,29 +42,47 @@ public static ImportTable.Builder convertImportTable(MTable table) {
name = table.get_Translation(I_AD_Table.COLUMNNAME_Name);
}

builder.setId(table.getAD_Table_ID())
builder.setId(
table.getAD_Table_ID()
)
.setUuid(
ValueManager.validateNull(
table.getUUID()
)
)
.setName(
ValueManager.validateNull(name)
)
.setTableName(table.getTableName())
;

table.getColumnsAsList().parallelStream().forEach(column -> {
table.getColumnsAsList().forEach(column -> {
String nameOfColumn = column.getName();
if (!isBaseLanguage) {
// set translated values
nameOfColumn = column.get_Translation(I_AD_Column.COLUMNNAME_Name);
}

ImportColumn.Builder columnBuilder = ImportColumn.newBuilder()
.setId(column.getAD_Column_ID())
.setId(
column.getAD_Column_ID()
)
.setUuid(
ValueManager.validateNull(
column.getUUID()
)
)
.setName(
ValueManager.validateNull(nameOfColumn)
)
.setColumnName(
ValueManager.validateNull(column.getColumnName())
ValueManager.validateNull(
column.getColumnName()
)
)
.setDisplayType(
column.getAD_Reference_ID()
)
.setDisplayType(column.getAD_Reference_ID())
;

builder.addImportColumns(columnBuilder);
Expand All @@ -80,21 +98,36 @@ public static ImportFormat.Builder convertImportFormat(MImpFormat importFormat)
return builder;
}

builder.setId(importFormat.getAD_ImpFormat_ID())
builder.setId(
importFormat.getAD_ImpFormat_ID()
)
.setUuid(
ValueManager.validateNull(
importFormat.getUUID()
)
)
.setName(
ValueManager.validateNull(importFormat.getName())
ValueManager.validateNull(
importFormat.getName()
)
)
.setDescription(
ValueManager.validateNull(importFormat.getDescription())
ValueManager.validateNull(
importFormat.getDescription()
)
)
.setTableName(
MTable.getTableName(Env.getCtx(), importFormat.getAD_Table_ID())
)
.setFormatType(
ValueManager.validateNull(importFormat.getFormatType())
ValueManager.validateNull(
importFormat.getFormatType()
)
)
.setSeparatorCharacter(
ValueManager.validateNull(importFormat.getSeparatorChar())
ValueManager.validateNull(
importFormat.getSeparatorChar()
)
)
;

Expand All @@ -114,31 +147,58 @@ public static FormatField.Builder convertFormatField(MImpFormatRow importFormatR
return builder;
}

builder.setId(importFormatRow.getAD_ImpFormat_Row_ID())
builder.setId(
importFormatRow.getAD_ImpFormat_Row_ID()
)
.setUuid(
ValueManager.validateNull(
importFormatRow.getUUID()
)
)
.setName(
ValueManager.validateNull(importFormatRow.getName())
ValueManager.validateNull(
importFormatRow.getName()
)
)
.setSequence(
importFormatRow.getSeqNo()
)
.setSequence(importFormatRow.getSeqNo())
.setColumnName(
MColumn.getColumnName(Env.getCtx(), importFormatRow.getAD_Column_ID())
)
.setDataType(
ValueManager.validateNull(importFormatRow.getDataType())
ValueManager.validateNull(
importFormatRow.getDataType()
)
)
.setStartNo(
importFormatRow.getStartNo()
)
.setEndNo(
importFormatRow.getEndNo()
)
.setStartNo(importFormatRow.getStartNo())
.setEndNo(importFormatRow.getEndNo())
.setDefaultValue(
ValueManager.validateNull(importFormatRow.getDefaultValue())
ValueManager.validateNull(
importFormatRow.getDefaultValue()
)
)
.setDefimalPoint(
ValueManager.validateNull(importFormatRow.getDecimalPoint())
ValueManager.validateNull(
importFormatRow.getDecimalPoint()
)
)
.setIsDivideBy100(
importFormatRow.isDivideBy100()
)
.setIsDivideBy100(importFormatRow.isDivideBy100())
.setDateFormat(
ValueManager.validateNull(importFormatRow.getDataFormat())
ValueManager.validateNull(
importFormatRow.getDataFormat()
)
)
.setConstantValue(
ValueManager.validateNull(importFormatRow.getConstantValue())
ValueManager.validateNull(
importFormatRow.getConstantValue()
)
)
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
************************************************************************************/
package org.spin.form.import_file_loader;
package org.spin.grpc.service.form.import_file_loader;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/spin/server/AllInOneServices.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.spin.grpc.service.Enrollment;
import org.spin.grpc.service.FileManagement;
import org.spin.grpc.service.GeneralLedger;
import org.spin.grpc.service.ImportFileLoader;
import org.spin.grpc.service.LogsInfo;
import org.spin.grpc.service.MaterialManagement;
import org.spin.grpc.service.NoticeManagement;
Expand Down Expand Up @@ -63,6 +62,7 @@
import org.spin.grpc.service.form.ExpressShipment;
import org.spin.grpc.service.form.PaymentAllocation;
import org.spin.grpc.service.form.bank_statement_match.BankStatementMatch;
import org.spin.grpc.service.form.import_file_loader.ImportFileLoader;
import org.spin.grpc.service.form.issue_management.IssueManagement;
import org.spin.grpc.service.form.match_po_receipt_invoice.MatchPOReceiptInvoice;
import org.spin.grpc.service.form.payroll_action_notice.PayrollActionNotice;
Expand Down
74 changes: 45 additions & 29 deletions src/main/proto/import_file_loader.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,24 @@ package import_file_loader;

service ImportFileLoader {
rpc ListCharsets(ListCharsetsRequest) returns (data.ListLookupItemsResponse) {
option (google.api.http) = { get: "/import-loader/charsets" };
option (google.api.http) = {
get: "/import-loader/charsets"
};
}
rpc ListImportTables(ListImportTablesRequest) returns (ListImportTablesResponse) {
option (google.api.http) = { get: "/import-loader/tables" };
option (google.api.http) = {
get: "/import-loader/tables"
};
}
rpc ListImportFormats(ListImportFormatsRequest) returns (data.ListLookupItemsResponse) {
option (google.api.http) = { get: "/import-loader/formats/{table_name}" };
option (google.api.http) = {
get: "/import-loader/formats/{table_name}"
};
}
rpc GetImportFromat(GetImportFromatRequest) returns (ImportFormat) {
option (google.api.http) = { get: "/import-loader/formats/get/{id}" };
option (google.api.http) = {
get: "/import-loader/formats/get/{id}"
};
}
// Manage File
rpc SaveRecords(SaveRecordsRequest) returns (SaveRecordsResponse) {
Expand All @@ -49,11 +57,15 @@ service ImportFileLoader {
};
}
rpc ListFilePreview(ListFilePreviewRequest) returns (data.ListEntitiesResponse) {
option (google.api.http) = { get: "/import-loader/imports/resource/preview/{import_format_id}" };
option (google.api.http) = {
get: "/import-loader/imports/resource/preview/{import_format_id}"
};
}
// Process
rpc ListImportProcesses(ListImportProcessesRequest) returns (data.ListLookupItemsResponse) {
option (google.api.http) = { get: "/import-loader/processes/{table_name}" };
option (google.api.http) = {
get: "/import-loader/processes/{table_name}"
};
}
}

Expand Down Expand Up @@ -84,16 +96,18 @@ message ListImportTablesRequest {

message ImportColumn {
int32 id = 1;
string name = 2;
string column_name = 3;
int32 display_type = 4;
string uuid = 2;
string name = 3;
string column_name = 4;
int32 display_type = 5;
}

message ImportTable {
int32 id = 1;
string name = 2;
string table_name = 3;
repeated ImportColumn import_columns = 4;
string uuid = 2;
string name = 3;
string table_name = 4;
repeated ImportColumn import_columns = 5;
}

message ListImportTablesResponse {
Expand Down Expand Up @@ -134,30 +148,32 @@ message ListClientImportFormatsRequest {

message ImportFormat {
int32 id = 1;
string name = 2;
string description = 3;
string table_name = 4;
string format_type = 5;
string separator_character = 6;
repeated FormatField format_fields = 7;
string uuid = 2;
string name = 3;
string description = 4;
string table_name = 5;
string format_type = 6;
string separator_character = 7;
repeated FormatField format_fields = 8;
}

message FormatField {
int32 id = 1;
string name = 2;
int32 sequence = 3;
string column_name = 4;
string data_type = 5;
int32 start_no = 6;
int32 end_no = 7;
string default_value = 8;
string uuid = 2;
string name = 3;
int32 sequence = 4;
string column_name = 5;
string data_type = 6;
int32 start_no = 7;
int32 end_no = 8;
string default_value = 9;
// number
string defimal_point = 9;
bool is_divide_by_100 = 10;
string defimal_point = 10;
bool is_divide_by_100 = 11;
// date
string date_format = 11;
string date_format = 12;
// constant
string constant_value = 12;
string constant_value = 13;
}

// Format Field
Expand Down

0 comments on commit fe7c421

Please sign in to comment.