Skip to content

Commit

Permalink
feat: Add mapping to Form entity.
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinBetanc0urt committed Mar 23, 2024
1 parent 1ae84af commit 16e8c01
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;

import org.adempiere.core.domains.models.I_AD_Browse;
import org.adempiere.core.domains.models.I_AD_Form;
import org.adempiere.core.domains.models.I_AD_Language;
import org.adempiere.core.domains.models.I_AD_Menu;
import org.adempiere.core.domains.models.I_AD_Process;
Expand All @@ -35,6 +36,7 @@
import org.spin.eca56.util.support.IGenericDocument;
import org.spin.eca56.util.support.IGenericSender;
import org.spin.eca56.util.support.documents.Browser;
import org.spin.eca56.util.support.documents.Form;
import org.spin.eca56.util.support.documents.Menu;
import org.spin.eca56.util.support.documents.Process;
import org.spin.eca56.util.support.documents.Window;
Expand Down Expand Up @@ -139,6 +141,8 @@ public IGenericDictionaryDocument getDocumentManager(PO entity, String language)
return Window.newInstance().withLanguage(language).withClientId(Env.getAD_Client_ID(entity.getCtx())).withEntity(entity);
} else if(tableName.equals(I_AD_Menu.Table_Name)) {
return Menu.newInstance().withLanguage(language).withClientId(Env.getAD_Client_ID(entity.getCtx())).withEntity(entity);
} else if (tableName.equals(I_AD_Form.Table_Name)) {
return Form.newInstance().withLanguage(language).withClientId(Env.getAD_Client_ID(entity.getCtx())).withEntity(entity);
}
return null;
}
Expand Down
89 changes: 89 additions & 0 deletions src/main/java/org/spin/eca56/util/support/documents/Form.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 or later of the *
* GNU General Public License as published *
* by the Free Software Foundation. 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, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* Copyright (C) 2003-2024 E.R.P. Consultores y Asociados, C.A. *
* All Rights Reserved. *
* Contributor(s): Edwin Betancourt, [email protected] *
*****************************************************************************/
package org.spin.eca56.util.support.documents;

import java.util.HashMap;
import java.util.Map;

import org.adempiere.core.domains.models.I_AD_Form;
import org.compiere.model.MForm;
import org.compiere.model.PO;
import org.compiere.util.Util;
import org.spin.eca56.util.support.DictionaryDocument;

/**
* the document class for Process senders
* @author Edwin Betancourt, [email protected], https://github.com/EdwinBetanc0urt
*/
public class Form extends DictionaryDocument {

// Some default documents key
public static final String KEY = "new";
public static final String CHANNEL = "form";


@Override
public String getKey() {
return KEY;
}


@Override
public DictionaryDocument withEntity(PO entity) {
MForm form = (MForm) entity;
Map<String, Object> documentDetail = new HashMap<>();
documentDetail.put("id", form.getAD_Form_ID());
documentDetail.put("uuid", form.getUUID());
documentDetail.put("name", form.get_Translation(I_AD_Form.COLUMNNAME_Name, getLanguage()));
documentDetail.put("description", form.get_Translation(I_AD_Form.COLUMNNAME_Description, getLanguage()));
documentDetail.put("help", form.get_Translation(I_AD_Form.COLUMNNAME_Help, getLanguage()));
documentDetail.put("is_active", form.isActive());

String fileName = form.getClassname();
if (!Util.isEmpty(fileName, true)) {
int beginIndex = fileName.lastIndexOf(".");
if (beginIndex == -1) {
beginIndex = 0;
} else {
beginIndex++;
}
fileName = form.getClassname().substring(beginIndex, fileName.length());
documentDetail.put("file_name", fileName);
}

putDocument(documentDetail);
return this;
}

private Form() {
super();
}

/**
* Default instance
* @return
*/
public static Form newInstance() {
return new Form();
}

@Override
public String getChannel() {
return CHANNEL;
}
}

0 comments on commit 16e8c01

Please sign in to comment.