Skip to content

Commit

Permalink
Merge pull request #1470 from metasfresh/gh523-wip2
Browse files Browse the repository at this point in the history
Gh523 wip2
  • Loading branch information
metas-ts committed May 8, 2017
2 parents 505c6db + 7aee3d7 commit d306ff5
Show file tree
Hide file tree
Showing 73 changed files with 3,951 additions and 848 deletions.
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
**/.settings/
*.cache
*.diff
*.project
*.classpath
**/.classpath
**/.project

**/activemq-data/
**/data/
**/log/

de.metas.endcustomer.mf15/metasfresh.properties
/de.metas.endcustomer.mf15/de.metas.endcustomer.mf15.swingui/log/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,10 @@ public List<Fact> createFacts(final MAcctSchema as)
// dr.setLocationFromLocator(m_receiptLine.getM_Locator_ID(), false); // to Loc
// Set AmtAcctCr/Dr from Receipt (sets also Project)
if (!dr.updateReverseLine(I_M_InOut.Table_ID, // Amt updated
m_receiptLine.getM_InOut_ID(), m_receiptLine.getM_InOutLine_ID(),
receiptQtyMultiplier))
m_receiptLine.getM_InOut_ID(),
m_receiptLine.getM_InOutLine_ID(),
receiptQtyMultiplier)
)
{
throw newPostingException()
.setC_AcctSchema(as)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
Expand Down Expand Up @@ -58,7 +59,6 @@
import org.compiere.model.MLanguage;
import org.compiere.swing.CFrame;
import org.slf4j.Logger;
import org.springframework.util.CollectionUtils;

import com.google.common.base.Supplier;

Expand Down Expand Up @@ -390,7 +390,25 @@ public static final Properties copyCtx(final Properties ctx)
Check.assumeNotNull(ctx, "ctx not null");

final Properties newCtx = new Properties();
CollectionUtils.mergePropertiesIntoMap(ctx, newCtx);

// we can't use this great tool, because it (reasonably) assumes that the given ctx doews not have null values
// org.springframework.util.CollectionUtils.mergePropertiesIntoMap(ctx, newCtx);

for (final Enumeration<?> en = ctx.propertyNames(); en.hasMoreElements();)
{
final String key = (String)en.nextElement();
Object value = ctx.get(key);
if (value == null)
{
// Allow for defaults fallback or potentially overridden accessor
value = newCtx.getProperty(key);
}
if (value == null)
{
continue; // the given ctx might have null values, so this chack is crucial
}
newCtx.put(key, value);
}

return newCtx;
}
Expand Down Expand Up @@ -1180,10 +1198,10 @@ public static int getAD_Role_ID(Properties ctx)
return Env.getContextAsInt(ctx, CTXNAME_AD_Role_ID);
} // getAD_Role_ID

// public static void setAD_Role_ID(Properties ctx, final int adRoleId)
// {
// Env.setContext(ctx, CTXNAME_AD_Role_ID, adRoleId);
// } // getAD_Role_ID
// public static void setAD_Role_ID(Properties ctx, final int adRoleId)
// {
// Env.setContext(ctx, CTXNAME_AD_Role_ID, adRoleId);
// } // getAD_Role_ID

public static IUserRolePermissions getUserRolePermissions()
{
Expand All @@ -1208,7 +1226,6 @@ public static IUserRolePermissions getUserRolePermissions(final String permissio
return Services.get(IUserRolePermissionsDAO.class).retrieveUserRolePermissions(userRolePermissionsKey);
}


public static void resetUserRolePermissions()
{
Services.get(IUserRolePermissionsDAO.class).resetCache();
Expand Down Expand Up @@ -1437,7 +1454,7 @@ public static void verifyLanguage(final Language language)

//
// Check if we have a perfect match
if(AD_Languages.contains(searchAD_Language))
if (AD_Languages.contains(searchAD_Language))
{
return;
}
Expand Down Expand Up @@ -1614,11 +1631,10 @@ public static String parseContext(Properties ctx, int WindowNo, IStringExpressio
return parseContext(ctx, WindowNo, expression, onlyWindow, ignoreUnparsable);
} // parseContext


/*************************************************************************/

// Array of active Windows
private static ArrayList<Container> s_windows = new ArrayList<Container>(20);
private static ArrayList<Container> s_windows = new ArrayList<>(20);

/**
* Add Container and return WindowNo. The container is a APanel, AWindow or JFrame/JDialog
Expand Down Expand Up @@ -1845,7 +1861,7 @@ public static boolean isWindows()
} // isWindows

/** Array of hidden Windows */
private static ArrayList<CFrame> s_hiddenWindows = new ArrayList<CFrame>();
private static ArrayList<CFrame> s_hiddenWindows = new ArrayList<>();
/** Closing Window Indicator */
private static boolean s_closingWindows = false;

Expand Down Expand Up @@ -1962,7 +1978,7 @@ public static void sleep(final int sec)
*/
public static Set<Window> updateUI()
{
Set<Window> updated = new HashSet<Window>();
Set<Window> updated = new HashSet<>();
for (Container c : s_windows)
{
Window w = getFrame(c);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
* 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
* <http://www.gnu.org/licenses/gpl-2.0.html>.
Expand Down Expand Up @@ -44,9 +44,9 @@

/**
* Filters out only records which are present in sub-query.
*
*
* @author tsa
*
*
* @param <T>
*/
public class InSubQueryFilter<T> implements IQueryFilter<T>, ISqlQueryFilter
Expand All @@ -66,7 +66,7 @@ public class InSubQueryFilter<T> implements IQueryFilter<T>, ISqlQueryFilter
private static final transient Logger logger = LogManager.getLogger(InSubQueryFilter.class);

/**
*
*
* @param columnName this query match column
* @param subQueryColumnName sub query match column
* @param subQuery sub query
Expand Down Expand Up @@ -132,7 +132,7 @@ private final void buildSql()
}

final TypedSqlQuery<?> subQueryImpl = TypedSqlQuery.cast(subQuery);

//
// Decide if we will render the SQL using "EXISTS (...)" (preferred option, at least of postresql) or "IN (...)".
final boolean useIN;
Expand All @@ -142,7 +142,7 @@ private final void buildSql()
// In case the sub query is done on the same table as the parent table, we can't write it with "EXISTS"
// Because we don't have aliases.
// Therefore, in such cases, we have to keep the writing with "IN"
logDevelopmentWarn("The query has to be written with IN instead of EXISTS because the tablename is the same for both query and sub query.");
//logDevelopmentWarn("The query has to be written with IN instead of EXISTS because the tablename is the same for both query and sub query.");
useIN = true;
}
else if (subQueryImpl.hasLimitOrOffset())
Expand Down Expand Up @@ -178,9 +178,9 @@ else if (subQueryImpl.hasLimitOrOffset())

/**
* Build the filter SQL using EXISTS.
*
*
* e.g. EXISTS (SELECT 1 FROM SubTable WHERE ParentTable.JoinColumn=SubTable.JoinColumn AND .....)
*
*
* @param subQueryImpl
* @return sql
*/
Expand All @@ -189,7 +189,7 @@ private String buildSql_UsingEXISTS(final TypedSqlQuery<?> subQueryImpl)
final String subQueryColumnNameWithModifier = modifier.getColumnSql(this.subQueryColumnName);

//
// Build the new sub-query's SELECT FROM
// Build the new sub-query's SELECT FROM
final StringBuilder subQuerySelectClause = new StringBuilder()
.append("SELECT 1 FROM ").append(subQueryImpl.getTableName());
final boolean subQueryUseOrderByClause = false;
Expand Down Expand Up @@ -232,9 +232,9 @@ private String buildSql_UsingEXISTS(final TypedSqlQuery<?> subQueryImpl)

/**
* Build the filter SQL using IN.
*
*
* e.g. ParentTable.JoinColumn IN (SELECT 1 FROM SubTable WHERE ...)
*
*
* @param subQueryImpl
* @return sql
*/
Expand All @@ -243,7 +243,7 @@ private String buildSql_UsingIN(final TypedSqlQuery<?> subQueryImpl)
final String subQueryColumnNameWithModifier = modifier.getColumnSql(this.subQueryColumnName);

//
// Build the new sub-query's SELECT FROM
// Build the new sub-query's SELECT FROM
final StringBuilder subQuerySelectClause = new StringBuilder()
.append("SELECT ").append(subQueryColumnNameWithModifier)
.append(" FROM ").append(subQueryImpl.getTableName());
Expand Down Expand Up @@ -279,7 +279,7 @@ private String buildSql_UsingIN(final TypedSqlQuery<?> subQueryImpl)
.append(")")
.toString();
}

private final void logDevelopmentWarn(final String message)
{
if (Services.get(IDeveloperModeBL.class).isEnabled())
Expand Down Expand Up @@ -322,7 +322,7 @@ private List<Object> getSubQueryValues(final T model)

final List<?> subQueryResult = subQuery.list();

final List<Object> subQueryValues = new ArrayList<Object>(subQueryResult.size());
final List<Object> subQueryValues = new ArrayList<>(subQueryResult.size());
for (Object subModel : subQueryResult)
{
final Object value0 = InterfaceWrapperHelper.getValue(subModel, this.subQueryColumnName).orNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public final <ModelType> ModelType retrieveModel(final Properties ctx, final Str
return model;
}
}

public void invalidateCache(final String tableName, final int recordId, final String trxName)
{
final IModelCacheService modelCacheService = Services.get(IModelCacheService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public static <T> T newInstance(final Class<T> cl)
*
* @param model the underlying {@link PO}, {@link GridTab} or POJO for which we need an instance of <code>cl</code>
* @param cl the interface we need an instance of
* @return and instance of <code>cl</code> which actually wraps <code>model</code> or <code>null</code> if model was <code>null</code>
* @return an instance of <code>cl</code> which actually wraps <code>model</code> or <code>null</code> if model was <code>null</code>
*/
public static <T> T create(final Object model, final Class<T> cl)
{
Expand Down Expand Up @@ -315,7 +315,7 @@ public static <T> T create(final Properties ctx, final String tableName, final i
/**
* Loads given model, out of transaction.
* NOTE: to be used, mainly for loading master data models.
*
*
* @param id model's ID
* @param modelClass
* @return loaded model
Expand All @@ -324,10 +324,10 @@ public static <T> T loadOutOfTrx(final int id, final Class<T> modelClass)
{
return create(Env.getCtx(), id, modelClass, ITrx.TRXNAME_None);
}

/**
* Loads given model, using thread inherited transaction.
*
*
* @param id model's ID
* @param modelClass
* @return loaded model
Expand Down Expand Up @@ -770,7 +770,7 @@ public static String getTableNameOrNull(final Class<?> clazz)
* If the modelClass does not have a table name it will return <code>expectedTableName</code> if that's not null.
* If the modelClass has a table name but it's not matching the expectedTableName (if not null) an exception will be thrown.
* If the modelClass does not hava a table name and <code>expectedTableName</code> is null an exception will be thrown.
*
*
* @param modelClass
* @param expectedTableName
* @return model table name; never returns null
Expand Down

0 comments on commit d306ff5

Please sign in to comment.