Skip to content

Commit

Permalink
Merge branch 'master' into bndtools
Browse files Browse the repository at this point in the history
  • Loading branch information
hengsin committed Oct 27, 2024
2 parents 5b2846c + fc6795b commit 5cd39cb
Show file tree
Hide file tree
Showing 65 changed files with 1,218 additions and 313 deletions.
18 changes: 18 additions & 0 deletions migration/iD12/oracle/202410151415_IDEMPIERE-6171.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- IDEMPIERE-6171 Request and request group window is showing fields for de-activated window
SELECT register_migration_script('202410151415_IDEMPIERE-6171.sql') FROM dual;

SET SQLBLANKLINES ON
SET DEFINE OFF

-- Oct 15, 2024, 2:15:37 PM MYT
UPDATE AD_Field SET IsActive='N',Updated=TO_TIMESTAMP('2024-10-15 14:15:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12748
;

-- Oct 15, 2024, 2:16:28 PM MYT
UPDATE AD_Field SET IsActive='N',Updated=TO_TIMESTAMP('2024-10-15 14:16:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207655
;

-- Oct 15, 2024, 2:19:30 PM MYT
UPDATE AD_Field SET IsActive='N',Updated=TO_TIMESTAMP('2024-10-15 14:19:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12006
;

10 changes: 10 additions & 0 deletions migration/iD12/oracle/202410181336_IDEMPIERE-6262.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- IDEMPIERE-6262 UI Enhancements for Consistency with IceBlue_c Theme
SELECT register_migration_script('202410181336_IDEMPIERE-6262.sql') FROM dual;

SET SQLBLANKLINES ON
SET DEFINE OFF

-- Oct 18, 2024, 1:36:24 PM BRT
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('M','Login',0,0,'Y',TO_TIMESTAMP('2024-10-18 13:36:23','YYYY-MM-DD HH24:MI:SS'),10,TO_TIMESTAMP('2024-10-18 13:36:23','YYYY-MM-DD HH24:MI:SS'),10,200908,'LoginHeader','D','3b795676-7f94-4da3-a5c3-a9310c692f5e')
;

15 changes: 15 additions & 0 deletions migration/iD12/postgresql/202410151415_IDEMPIERE-6171.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- IDEMPIERE-6171 Request and request group window is showing fields for de-activated window
SELECT register_migration_script('202410151415_IDEMPIERE-6171.sql') FROM dual;

-- Oct 15, 2024, 2:15:37 PM MYT
UPDATE AD_Field SET IsActive='N',Updated=TO_TIMESTAMP('2024-10-15 14:15:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12748
;

-- Oct 15, 2024, 2:16:28 PM MYT
UPDATE AD_Field SET IsActive='N',Updated=TO_TIMESTAMP('2024-10-15 14:16:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207655
;

-- Oct 15, 2024, 2:19:30 PM MYT
UPDATE AD_Field SET IsActive='N',Updated=TO_TIMESTAMP('2024-10-15 14:19:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=12006
;

7 changes: 7 additions & 0 deletions migration/iD12/postgresql/202410181336_IDEMPIERE-6262.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- IDEMPIERE-6262 UI Enhancements for Consistency with IceBlue_c Theme
SELECT register_migration_script('202410181336_IDEMPIERE-6262.sql') FROM dual;

-- Oct 18, 2024, 1:36:24 PM BRT
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('M','Login',0,0,'Y',TO_TIMESTAMP('2024-10-18 13:36:23','YYYY-MM-DD HH24:MI:SS'),10,TO_TIMESTAMP('2024-10-18 13:36:23','YYYY-MM-DD HH24:MI:SS'),10,200908,'LoginHeader','D','3b795676-7f94-4da3-a5c3-a9310c692f5e')
;

Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,24 @@ private void createLine (MOrder order, MInOut ship, MInOutLine sLine)
MInvoiceLine line = new MInvoiceLine (m_invoice);
line.setShipLine(sLine);
if (sLine.sameOrderLineUOM())
{
MDocType docType = MDocType.get(ship.getC_DocType_ID());
if (docType.isShipConfirm()
&& (order.getInvoiceRule().equals(MOrder.INVOICERULE_AfterDelivery)
|| order.getInvoiceRule().equals(MOrder.INVOICERULE_AfterOrderDelivered)
|| order.getInvoiceRule().equals(MOrder.INVOICERULE_CustomerScheduleAfterDelivery))
&& sLine.getTargetQty() != null && sLine.getTargetQty().signum() != 0)
{
if (sLine.getQtyEntered().compareTo(sLine.getTargetQty()) == 0)
line.setQtyEntered(sLine.getMovementQty());
else
line.setQtyEntered(sLine.getMovementQty()
.multiply(sLine.getQtyEntered())
.divide(sLine.getTargetQty(), 12, RoundingMode.HALF_UP));
}
else
line.setQtyEntered(sLine.getQtyEntered());
}
else
line.setQtyEntered(sLine.getMovementQty());
line.setQtyInvoiced(sLine.getMovementQty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,13 +909,19 @@ public static void generateSource(String type, String sourceFolder, String packa
{
pstmt = DB.prepareStatement(sql.toString(), null);
rs = pstmt.executeQuery();

boolean isEmpty = true;
while (rs.next())
{
isEmpty = false;
if (type.equals(GEN_SOURCE_INTERFACE))
new ModelInterfaceGenerator(rs.getInt(1), directory.toString(), packageName, columnFilter);
else if (type.equals(GEN_SOURCE_CLASS))
new ModelClassGenerator(rs.getInt(1), directory.toString(), packageName, columnFilter);
}

if (isEmpty)
System.out.println("No data found for the table with name " + tableName);
}
catch (SQLException e)
{
Expand Down
11 changes: 10 additions & 1 deletion org.adempiere.base/src/org/compiere/acct/Doc.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Properties;
import java.util.logging.Level;

import org.adempiere.exceptions.AdempiereException;
import org.adempiere.exceptions.DBException;
import org.compiere.model.I_C_AllocationHdr;
import org.compiere.model.I_C_Cash;
Expand Down Expand Up @@ -684,7 +685,15 @@ else if (isPosted())
.append(" - " + Msg.getElement(Env.getCtx(),"IsBalanced") + "=").append( Msg.getMsg(Env.getCtx(), String.valueOf(isBalanced())))
.append(" - " + Msg.getElement(Env.getCtx(),"C_AcctSchema_ID") + "=").append(m_as.getName());
note.setTextMsg(Text.toString());
note.saveEx();
try {
note.saveEx();
} catch (AdempiereException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Foreign ID " + p_po.get_ID() + " not found in ")) {
; //ignore, in unit test
} else {
throw e;
}
}
p_Error = Text.toString();
}

Expand Down
26 changes: 26 additions & 0 deletions org.adempiere.base/src/org/compiere/model/AttachmentData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/***********************************************************************
* This file is part of iDempiere ERP Open Source *
* http://www.idempiere.org *
* *
* Copyright (C) Contributors *
* *
* 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, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
**********************************************************************/
package org.compiere.model;

public record AttachmentData(String name, byte[] data) {

}
3 changes: 2 additions & 1 deletion org.adempiere.base/src/org/compiere/model/GridTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -2878,7 +2878,8 @@ private void processDependencies (GridField changedField)
MLookup mLookup = (MLookup)dependentField.getLookup();
// if the lookup is dynamic (i.e. contains this columnName as variable)
if (mLookup.getValidation().indexOf("@"+columnName+"@") != -1
|| mLookup.getValidation().matches(".*[@]"+columnName+"[:].+[@].*$"))
|| mLookup.getValidation().matches(".*[@]"+getTabNo()+"[|]"+columnName+"([:].+)?[@].*")
|| mLookup.getValidation().matches(".*[@][~]?"+columnName+"([:].+)?[@].*"))
{
if (log.isLoggable(Level.FINE)) log.fine(columnName + " changed - "
+ dependentField.getColumnName() + " set to null");
Expand Down
121 changes: 121 additions & 0 deletions org.adempiere.base/src/org/compiere/model/MAttachment.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import org.adempiere.exceptions.AdempiereException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Target;
import org.apache.tools.ant.taskdefs.Zip;
import org.compiere.print.layout.ImageElement;
import org.compiere.tools.FileUtil;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
Expand All @@ -59,6 +62,8 @@ public class MAttachment extends X_AD_Attachment
*/
private static final long serialVersionUID = 5615231734722570658L;

private static final String ATTACHMENT_URL_PREFIX = "attachment:";

/**
* @param ctx
* @param AD_Table_ID
Expand Down Expand Up @@ -748,4 +753,120 @@ public void setStorageProvider(MStorageProvider p) {
setAD_StorageProvider_ID(p.getAD_StorageProvider_ID());
}

/**
* Get attachment data from path expression and id
* @param path attachment/tableName/index or filename
* @param id record id or record uuid
* @return data of attachment item
*/
public static AttachmentData getAttachmentData(String path, Object id) {
String[] parts;
//record_id or record_uu
if ((id instanceof Number) || (id instanceof String)) {
parts = path.split("[/]");
//expression syntax - attachment/table name/index or name
if (parts.length == 3) {
String tableName = parts[1];
MTable table = MTable.get(Env.getCtx(), tableName);
if (table != null) {
int recordId = (id instanceof Number) ? ((Number)id).intValue() : -1;
String recordUU = (id instanceof String) ? (String)id : null;
// check security
if (!MRole.getDefault().checkAccessSQL(table, recordId, recordUU, false))
return null;
MAttachment attachment = MAttachment.get(Env.getCtx(), table.get_ID(), recordId, recordUU, null);
if (attachment != null && attachment.get_ID() > 0) {
//first, check whether is via index
int index = -1;
if (parts[2].trim().matches("[0-9]+")) {
try {
index = Integer.parseInt(parts[2]);
} catch (Exception e) {
}
}
if (index >= 0 && index < attachment.getEntryCount()) {
return new AttachmentData(attachment.getEntryName(index), attachment.getEntryData(index));
}
//try name
String toMatch = null;
if (parts[2].contains("*")) {
//wildcard match, for e.g a*.png
Pattern regex = Pattern.compile("[^*]+|(\\*)");
Matcher m = regex.matcher(parts[2]);
StringBuffer b= new StringBuffer();
while (m.find()) {
if(m.group(1) != null) m.appendReplacement(b, ".*");
else m.appendReplacement(b, "\\\\Q" + m.group(0) + "\\\\E");
}
m.appendTail(b);
toMatch = b.toString();
}
for(int i = 0; i < attachment.getEntryCount(); i++) {
if (toMatch != null && attachment.getEntryName(i) != null && attachment.getEntryName(i).matches(toMatch)) {
return new AttachmentData(attachment.getEntryName(i), attachment.getEntryData(i));
} else if (parts[2].equals(attachment.getEntryName(i))) {
return new AttachmentData(attachment.getEntryName(i), attachment.getEntryData(i));
}
}
}
}
}
}
return null;
}

/**
* Get web image attachment url from attachment: expression
* @param contextPath web context path (not needed for zk component, pass null instead)
* @param path attachment:{tableName}/{index or filename pattern},{record id or uuid}
* @return image attachment url
*/
public static String getImageAttachmentURLFromPath(String contextPath, String path) {
String[] part = path.trim().split(",");
if (part.length == 2)
{
String expression = part[0];
//convert from attachment: url syntax to attachment/ path syntax
expression = expression.replaceFirst("[:]", "/");
StringBuilder url = new StringBuilder(contextPath != null ? contextPath : "")
.append("/aimages?path=")
.append(expression)
.append("&recordid=")
.append(part[1]);
return url.toString();
}
return null;
}

/**
* Is attachment URL path
* @param path attachment:table/{index or file name pattern},{record id or uuid}
* @return true if path is attachment path
*/
public static boolean isAttachmentURLPath(String path) {
return path != null && path.startsWith(ATTACHMENT_URL_PREFIX) && path.indexOf(",") > 0;
}

/**
* Get attachment data from attachment URL path
* @param path attachment:table/{index or file name pattern},{record id or uuid}
* @return attachment data or null
*/
public static AttachmentData getDataFromAttachmentURLPath(String path) {
String[] part = path.trim().split(",");
if (part.length == 2)
{
try {
String expression = part[0];
//convert from attachment: url syntax to attachment/ path syntax
expression = expression.replaceFirst("[:]", "/");
Object key = part[1].length() == 36 ? part[1] : Integer.parseInt(part[1]);
AttachmentData imageData = MAttachment.getAttachmentData(expression, key);
return imageData;
} catch (Exception e) {
CLogger.getCLogger(ImageElement.class).log(Level.WARNING, e.getLocalizedMessage(), e);
}
}
return null;
}
} // MAttachment
33 changes: 31 additions & 2 deletions org.adempiere.base/src/org/compiere/model/MChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@
**********************************************************************/
package org.compiere.model;

import java.awt.image.BufferedImage;
import java.sql.ResultSet;
import java.util.List;
import java.util.Properties;

import org.adempiere.apps.graph.ChartBuilder;
import org.compiere.util.Env;
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.JFreeChart;

/**
* Extended model class for AD_Chart
Expand All @@ -34,8 +38,8 @@ public class MChart extends X_AD_Chart {
/**
* generated serial id
*/
private static final long serialVersionUID = 5720760885280644477L;
private static final long serialVersionUID = 6510636131425272970L;

private int windowNo=0;

/**
Expand Down Expand Up @@ -90,4 +94,29 @@ public void setWindowNo(int windowNo) {
public int getWindowNo() {
return windowNo;
}

/**
* Get chart image
* @param id
* @param width
* @param height
* @return chart image
*/
public BufferedImage getChartImage(int width, int height) {
if (width <= 0)
width = getWinHeight();
if (width <= 0)
width = 100; // default
if (height <= 0)
height = getWinHeight(); // default to make a square
if (height <= 0)
height = 100; // default to make a square of 100px
ChartBuilder chartBuilder = new ChartBuilder(this);
JFreeChart chart = chartBuilder.createChart();
chart.getPlot().setForegroundAlpha(0.8f);
ChartRenderingInfo info = new ChartRenderingInfo();
BufferedImage bi = chart.createBufferedImage(width, height, BufferedImage.TRANSLUCENT, info);
return bi;
}

}
25 changes: 25 additions & 0 deletions org.adempiere.base/src/org/compiere/model/MRole.java
Original file line number Diff line number Diff line change
Expand Up @@ -3448,4 +3448,29 @@ public MRole markImmutable() {
return this;
}

/**
* Check record access through {@link #addAccessSQL(String, String, boolean, boolean)} using<br/>
* either record id or record uuid
* @param table
* @param recordId ignore if uuid is use
* @param uuid null to use recordId
* @param rw true for writable, false for readonly
* @return true if role has access to record
*/
public boolean checkAccessSQL(MTable table, int recordId, String uuid, boolean rw) {
StringBuilder sql = new StringBuilder("SELECT 1 FROM ")
.append(table.getTableName())
.append(" WHERE ")
.append(table.getTableName())
.append(".");
if (!Util.isEmpty(uuid, true) ) {
sql.append(PO.getUUIDColumnName(table.getTableName()))
.append("=?");
return DB.getSQLValueEx(null, addAccessSQL(sql.toString(), table.getTableName(), true, rw), uuid) == 1;
} else {
sql.append(table.getKeyColumns()[0])
.append("=?");
return DB.getSQLValueEx(null, addAccessSQL(sql.toString(), table.getTableName(), true, rw), recordId) == 1;
}
}
} // MRole
Loading

0 comments on commit 5cd39cb

Please sign in to comment.