/************************************************************************************
 * Copyright (C) 2012-2018 E.R.P. Consultores y Asociados, C.A.                     *
 * Contributor(s): Yamel Senih ysenih@erpya.com                                     *
 * This program is free software: you can redistribute it and/or modify             *
 * it under the terms of the GNU General Public License as published by             *
 * the Free Software Foundation, either version 2 of the License, or                *
 * (at your option) any later version.                                              *
 * This program is distributed in the hope that it will be useful,                  *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the                     *
 * GNU General Public License for more details.                                     *
 * You should have received a copy of the GNU General Public License                *
 * along with this program.	If not, see <https://www.gnu.org/licenses/>.            *
 ************************************************************************************/
syntax = "proto3";

option java_multiple_files = true;
option java_package = "org.spin.grpc.util";
option java_outer_classname = "ADempiereDictionary";
option objc_class_prefix = "HLW";

package dictionary;

// The greeting service definition.
service Dictionary {
	// Request a Window
	rpc GetWindow(EntityRequest) returns (Window) {}
	// Request Window and tabs
	rpc GetWindowAndTabs(EntityRequest) returns (Window) {}
	// Request a Tab
	rpc GetTab(EntityRequest) returns (Tab) {}
	// Request a Tab and Fields
	rpc GetTabAndFields(EntityRequest) returns (Tab) {}
	// Request a Field
	rpc GetField(FieldRequest) returns (Field) {}
	// Reference Request
	rpc GetReference(ReferenceRequest) returns (Reference) {}
	// Reference Request
	rpc GetValidationRule(ValidationRuleRequest) returns (ValidationRule) {}
	// Request Process
	rpc GetProcess(EntityRequest) returns (Process) {}
	// Request Browser
	rpc GetBrowser(EntityRequest) returns (Browser) {}
	// Get Form
	rpc GetForm(EntityRequest) returns (Form) {}
}


// The client request contains client info for request.
message ApplicationRequest {
	string sessionUuid = 1;
	string language = 2;
}

// Object request
message EntityRequest {
	int32 id = 1;
	string uuid = 2;
	ApplicationRequest applicationRequest = 3;
}

// Field request
message FieldRequest {
	ApplicationRequest applicationRequest = 1;
	string fieldUuid = 2;
	string columnUuid = 3;
	string elementUuid = 4;
	// TableName + ColumnName
	string tableName = 5;
	string columnName = 6;
	string elementColumnName = 7;
}

// Reference request
message ReferenceRequest {
	ApplicationRequest applicationRequest = 1;
	string referenceUuid = 2;
	// TableName + ColumnName assumed that it is Table Direct
	string columnName = 3;
}

// Validation Code request
message ValidationRuleRequest {
	ApplicationRequest applicationRequest = 1;
	string validationRuleUuid = 2;
}

// Validation Code
message ValidationRule {
	string validationRuleUuid = 1;
	string validationCode = 2;
	string name = 3;
	string description = 4;
	string type = 5;
}

// Window
message Window {
	int32 id = 1;
	string uuid = 2;
	string name = 3;
	string description = 4;
	string help = 5;
	bool isActive = 6;
	bool isSOTrx = 7;
	string windowType = 8;
	//	External Info
	ContextInfo contextInfo = 9;
	repeated Tab tabs = 10;
}

// Tab
message Tab {
	int32 id = 1;
	string uuid = 2;
	string name = 3;
	string description = 4;
	string help = 5;
	// Attributes
	string tableName = 6;
	int32 sequence = 7;
	int32 tabLevel = 8;
	//
	bool isActive = 9;
	bool isSingleRow = 10;
	bool isAdvancedTab = 11;
	bool isHasTree = 12;
	bool isInfoTab = 13;
	bool isSortTab = 14;
	bool isTranslationTab = 15;
	bool isReadOnly = 16;
	bool isInsertRecord = 17;
	bool isView = 18;
	bool isDeleteable = 19;
	bool isDocument = 20;
	bool isChangeLog = 21;
	int32 accessLevel = 22;
	string linkColumnName = 23;
	string sortOrderColumnName = 24;
	string sortYesNoColumnName = 25;
	string parentColumnName = 26;
	string displayLogic = 27;
	string commitWarning = 28;
	string query = 29;
	string whereClause = 30;
	string orderByClause = 31;
	string parentTabUuid = 32;
	// External Info
	ContextInfo contextInfo = 33;
	repeated Process processes = 34;
	repeated Field fields = 35;
	FieldGroup fieldGroup = 36;
}

// Field
message Field {
	int32 id = 1;
	string uuid = 2;
	string name = 3;
	string description = 4;
	string help = 5;
	int32 sequence = 6;
	string columnName = 7;
	string elementName = 8;
	bool isDisplayed = 9;
	bool isDisplayedGrid = 10;
	bool isReadOnly = 11;
	bool isAllowCopy = 12;
	bool isEncrypted = 13;
	bool isSameLine = 14;
	bool isHeading = 15;
	bool isFieldOnly = 16;
	bool isQuickEntry = 17;
	bool isMandatory = 18;
	bool isKey = 19;
	bool isParent = 20;
	bool isUpdateable = 21;
	bool isIdentifier = 22;
	bool isAllowLogging = 23;
	bool isSelectionColumn = 24;
	bool isRange = 25;
	bool isAlwaysUpdateable = 26;
	bool isTranslated = 27;
	int32 identifierSequence = 78;
	string displayLogic = 29;
	int32 displayType = 30;
	string defaultValue = 31;
	string readOnlyLogic = 32;
	string mandatoryLogic = 33;
	string callout = 34;
	string columnSQL = 35;
	string vFormat = 36;
	string valueMin = 37;
	string valueMax = 38;
	string formatPattern = 39;
	// External Info
	ContextInfo contextInfo = 40;
	FieldGroup fieldGroup = 41;
	FieldDefinition fieldDefinition = 42;
	Reference reference = 43;
	Process process = 44;
	// Smart Browser Field Compatibility
	bool isQueryCriteria = 45;
	bool isOrderBy = 46;
	int32 seqNoGrid = 47;
	int32 sortNo = 48;
	bool isInfoOnly = 49;
	bool isActive = 50;
	// Process Parameter Compatibility
	string defaultValueTo = 51;
	int32 fieldLength = 52;
}

// Context Info
message ContextInfo {
	int32 id = 1;
	string uuid = 2;
	string name = 3;
	string description = 4;
	MessageText messageText = 5;
	string sqlStatement = 6;
	bool isActive = 7;
}

// Message
message MessageText {
	int32 id = 1;
	string uuid = 2;
	string value = 3;
	string msgType = 4;
	string msgText = 5;
	string msgTip = 6;
	bool isActive = 7;
}

// Context Info
message FieldGroup {
	int32 id = 1;
	string uuid = 2;
	string name = 3;
	string fieldGroupType = 4;
	bool isActive = 5;
}

// Context Info
message FieldDefinition {
	int32 id = 1;
	string uuid = 2;
	string value = 3;
	string name = 4;
	string fieldGroupType = 5;
	repeated FieldCondition conditions = 6;
	bool isActive = 7;
}

// Field Condition
message FieldCondition {
	int32 id = 1;
	string uuid = 2;
	string condition = 3;
	string stylesheet = 4;
	bool isActive = 5;
}

// Process
message Process {
	int32 id = 1;
	string uuid = 2;
	string value = 3;
	string name = 4;
	string description = 5;
	string help = 6;
	bool isReport = 7;
	int32 accessLevel = 8;
	string showHelp = 9;
	bool isDirectPrint = 10;
	repeated Field parameters = 11;
	bool isActive = 12;
	// Reporty Type
	repeated ReportExportType reportExportTypes = 13;
}

// Form
message Form {
	int32 id = 1;
	string uuid = 2;
	string name = 3;
	string description = 4;
	string help = 5;
	int32 accessLevel = 6;
	string fileName = 7;
	bool isActive = 8;
}

// Smart Browser
message Browser {
	int32 id = 1;
	string uuid = 2;
	string value = 3;
	string name = 4;
	string description = 5;
	string help = 6;
	int32 accessLevel = 8;
	string query = 9;
	string whereClause = 10;
	string orderByClause = 11;
	bool isUpdateable = 12;
	bool IsDeleteable = 13;
	bool IsSelectedByDefault = 14;
	bool IsCollapsibleByDefault = 15;
	bool IsExecutedQueryByDefault = 16;
	bool IsShowTotal = 17;
	string viewUuid = 18;
	// External Reference
	Window window = 19;
	Process process = 20;
	repeated Field fields = 21;
	bool isActive = 22;
}

// Zoom Window
message ZoomWindow {
	int32 id = 1;
	string uuid = 2;
	string name = 3;
	string description = 4;
	bool isSOTrx = 5;
	bool isActive = 6;
}

// Foreign Reference
message Reference {
	string tableName = 1;
	string keyColumnName = 2;
	string displayColumnName = 3;
	string query = 4;
	string directQuery = 5;
	string validationCode = 6;
	// External Info
	repeated ZoomWindow windows = 7;
}

// Report Type for Export
message ReportExportType {
	string name = 1;
	string description = 2;
	string type = 3;
}
