use of org.compiere.util.AdempiereSystemError in project adempiere by adempiere.
the class AcctSchemaCopyAcct method copyDefault.
// copyGL
/**
* Copy Default
* @param targetAS target
* @throws Exception
*/
private void copyDefault(MAcctSchema targetAS) throws Exception {
MAcctSchemaDefault source = MAcctSchemaDefault.get(getCtx(), p_SourceAcctSchema_ID);
MAcctSchemaDefault target = new MAcctSchemaDefault(getCtx(), 0, get_TrxName());
target.setC_AcctSchema_ID(p_TargetAcctSchema_ID);
target.setC_AcctSchema_ID(p_TargetAcctSchema_ID);
ArrayList<KeyNamePair> list = source.getAcctInfo();
for (int i = 0; i < list.size(); i++) {
KeyNamePair pp = list.get(i);
int sourceC_ValidCombination_ID = pp.getKey();
String columnName = pp.getName();
MAccount sourceAccount = MAccount.get(getCtx(), sourceC_ValidCombination_ID);
MAccount targetAccount = createAccount(targetAS, sourceAccount);
target.setValue(columnName, new Integer(targetAccount.getC_ValidCombination_ID()));
}
if (!target.save())
throw new AdempiereSystemError("Could not Save Default");
}
use of org.compiere.util.AdempiereSystemError in project adempiere by adempiere.
the class FindWindow method getSubCategoryWhereClause.
// isProductCategoryField
/**
* Returns a sql where string with the given category id and all of its subcategory ids.
* It is used as restriction in MQuery.
* @param productCategoryId
* @return
**/
private String getSubCategoryWhereClause(int productCategoryId) {
//if a node with this id is found later in the search we have a loop in the tree
int subTreeRootParentId = 0;
String retString = " M_Product_Category_ID IN (";
String sql = " SELECT M_Product_Category_ID, M_Product_Category_Parent_ID FROM M_Product_Category";
final Vector<SimpleTreeNode> categories = new Vector<SimpleTreeNode>(100);
try {
Statement stmt = DB.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
if (rs.getInt(1) == productCategoryId) {
subTreeRootParentId = rs.getInt(2);
}
categories.add(new SimpleTreeNode(rs.getInt(1), rs.getInt(2)));
}
retString += getSubCategoriesString(productCategoryId, categories, subTreeRootParentId);
retString += ") ";
rs.close();
stmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
retString = "";
} catch (AdempiereSystemError e) {
log.log(Level.SEVERE, sql, e);
retString = "";
}
return retString;
}
use of org.compiere.util.AdempiereSystemError in project adempiere by adempiere.
the class MSLACriteria method newInstance.
// getGoals
/**
* Create New Instance of SLA Criteria
* @return instanciated class
* @throws Exception
*/
public SLACriteria newInstance() throws Exception {
if (getClassname() == null || getClassname().length() == 0)
throw new AdempiereSystemError("No SLA Criteria Classname");
try {
Class clazz = Class.forName(getClassname());
SLACriteria retValue = (SLACriteria) clazz.newInstance();
return retValue;
} catch (Exception e) {
throw new AdempiereSystemError("Could not intsnciate SLA Criteria", e);
}
}
use of org.compiere.util.AdempiereSystemError in project adempiere by adempiere.
the class IssueReport method doIt.
// prepare
/**
* Do It
* @return info
* @throws Exception
*/
protected String doIt() throws Exception {
log.info("AD_Issue_ID=" + m_AD_Issue_ID);
if (!MSystem.get(getCtx()).isAutoErrorReport())
return "NOT reported - Enable Error Reporting in Window System";
//
MIssue issue = new MIssue(getCtx(), m_AD_Issue_ID, get_TrxName());
if (issue.get_ID() == 0)
return "No Issue to report - ID=" + m_AD_Issue_ID;
//
String error = issue.report();
if (error != null)
throw new AdempiereSystemError(error);
if (issue.save())
return "Issue Reported: " + issue.getRequestDocumentNo();
throw new AdempiereSystemError("Issue Not Saved");
}
use of org.compiere.util.AdempiereSystemError in project adempiere by adempiere.
the class InventoryCountCreate method getSubCategoriesString.
/**
* Recursive search for subcategories with loop detection.
* @param productCategoryId
* @param categories
* @param loopIndicatorId
* @return comma seperated list of category ids
* @throws AdempiereSystemError if a loop is detected
*/
private String getSubCategoriesString(int productCategoryId, Vector<SimpleTreeNode> categories, int loopIndicatorId) throws AdempiereSystemError {
String ret = "";
final Iterator iter = categories.iterator();
while (iter.hasNext()) {
SimpleTreeNode node = (SimpleTreeNode) iter.next();
if (node.getParentId() == productCategoryId) {
if (node.getNodeId() == loopIndicatorId) {
throw new AdempiereSystemError("The product category tree contains a loop on categoryId: " + loopIndicatorId);
}
ret = ret + getSubCategoriesString(node.getNodeId(), categories, loopIndicatorId) + ",";
}
}
log.fine(ret);
return ret + productCategoryId;
}
Aggregations