use of org.adempiere.pipo2.PoFiller in project idempiere by idempiere.
the class ReferenceElementHandler method startElement.
public void startElement(PIPOContext ctx, Element element) throws SAXException {
String entitytype = getStringValue(element, "EntityType");
if (isProcessElement(ctx.ctx, entitytype)) {
MReference mReference = findPO(ctx, element);
if (mReference == null) {
mReference = new MReference(ctx.ctx, 0, getTrxName(ctx));
}
List<String> excludes = defaultExcludeList(MReference.Table_Name);
PoFiller filler = new PoFiller(ctx, mReference, element, this);
List<String> notfounds = filler.autoFill(excludes);
if (notfounds.size() > 0) {
element.defer = true;
element.unresolved = notfounds.toString();
return;
}
element.recordId = mReference.getAD_Reference_ID();
if (mReference.is_new() || mReference.is_Changed()) {
X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, MReference.Table_Name, MReference.Table_ID);
String action = null;
if (!mReference.is_new()) {
if (references.contains(mReference.getAD_Reference_ID())) {
element.skip = true;
return;
}
backupRecord(ctx, impDetail.getAD_Package_Imp_ID(), MReference.Table_Name, mReference);
action = "Update";
} else {
action = "New";
}
if (mReference.save(getTrxName(ctx)) == true) {
logImportDetail(ctx, impDetail, 1, mReference.getName(), mReference.get_ID(), action);
references.add(mReference.getAD_Reference_ID());
element.recordId = mReference.getAD_Reference_ID();
} else {
logImportDetail(ctx, impDetail, 0, mReference.getName(), mReference.get_ID(), action);
throw new POSaveFailedException("Failed to save Reference " + mReference.getName());
}
}
} else {
element.skip = true;
}
}
use of org.adempiere.pipo2.PoFiller in project idempiere by idempiere.
the class RoleElementHandler method startElement.
public void startElement(PIPOContext ctx, Element element) throws SAXException {
List<String> excludes = defaultExcludeList(X_AD_Role.Table_Name);
MRole mRole = findPO(ctx, element);
if (mRole == null) {
mRole = new MRole(ctx.ctx, 0, getTrxName(ctx));
}
PoFiller filler = new PoFiller(ctx, mRole, element, this);
List<String> notfounds = filler.autoFill(excludes);
if (notfounds.size() > 0) {
element.defer = true;
element.unresolved = notfounds.toString();
return;
}
if (mRole.is_new() || mRole.is_Changed()) {
X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_Role.Table_Name, X_AD_Role.Table_ID);
String action = null;
if (!mRole.is_new()) {
action = "Update";
} else {
action = "New";
}
if (mRole.save(getTrxName(ctx)) == true) {
element.recordId = mRole.getAD_Role_ID();
logImportDetail(ctx, impDetail, 1, mRole.getName(), mRole.get_ID(), action);
element.requireRoleAccessUpdate = true;
} else {
logImportDetail(ctx, impDetail, 0, mRole.getName(), mRole.get_ID(), action);
throw new POSaveFailedException("Failed to save Role " + mRole.getName());
}
}
}
use of org.adempiere.pipo2.PoFiller in project idempiere by idempiere.
the class DynValRuleElementHandler method startElement.
public void startElement(PIPOContext ctx, Element element) throws SAXException {
String entitytype = getStringValue(element, "EntityType");
if (isProcessElement(ctx.ctx, entitytype)) {
X_AD_Val_Rule mValRule = findPO(ctx, element);
if (mValRule == null) {
mValRule = new X_AD_Val_Rule(ctx.ctx, 0, getTrxName(ctx));
}
List<String> excludes = defaultExcludeList(X_AD_Val_Rule.Table_Name);
PoFiller filler = new PoFiller(ctx, mValRule, element, this);
List<String> notfounds = filler.autoFill(excludes);
if (notfounds.size() > 0) {
element.defer = true;
element.unresolved = notfounds.toString();
return;
}
if (mValRule.is_new() || mValRule.is_Changed()) {
X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_Val_Rule.Table_Name, X_AD_Val_Rule.Table_ID);
String action = null;
if (!mValRule.is_new()) {
backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), X_AD_Val_Rule.Table_Name, mValRule);
action = "Update";
} else {
action = "New";
}
if (mValRule.save(getTrxName(ctx)) == true) {
logImportDetail(ctx, impDetail, 1, mValRule.getName(), mValRule.get_ID(), action);
} else {
logImportDetail(ctx, impDetail, 0, mValRule.getName(), mValRule.get_ID(), action);
throw new POSaveFailedException("Failed to save dynamic validation rule " + mValRule.getName());
}
}
} else {
element.skip = true;
}
}
use of org.adempiere.pipo2.PoFiller in project idempiere by idempiere.
the class FormAccessElementHandler method startElement.
public void startElement(PIPOContext ctx, Element element) throws SAXException {
List<String> excludes = defaultExcludeList(X_AD_Form_Access.Table_Name);
MFormAccess po = findPO(ctx, element);
if (po == null) {
po = new MFormAccess(ctx.ctx, 0, getTrxName(ctx));
}
PoFiller filler = new PoFiller(ctx, po, element, this);
List<String> notfounds = filler.autoFill(excludes);
if (notfounds.size() > 0) {
element.defer = true;
element.unresolved = notfounds.toString();
return;
}
po.saveEx();
}
use of org.adempiere.pipo2.PoFiller in project idempiere by idempiere.
the class GenericPOElementHandler method startElement.
public void startElement(PIPOContext ctx, Element element) throws SAXException {
String tableName = element.getElementValue();
PO po = findPO(ctx, element);
if (po == null) {
MTable table = MTable.get(ctx.ctx, tableName);
po = table.getPO(0, getTrxName(ctx));
}
PoFiller filler = new PoFiller(ctx, po, element, this);
List<String> excludes = defaultExcludeList(tableName);
List<String> notfounds = filler.autoFill(excludes);
/* Verify if the table has entitytype and check dictionary maintenance */
int idxet = po.get_ColumnIndex("EntityType");
if (idxet >= 0) {
String entityType = (String) po.get_Value(idxet);
if (!isProcessElement(ctx.ctx, entityType)) {
if (log.isLoggable(Level.INFO))
log.info("Generic PO not processed as it's official " + po.toString());
element.skip = true;
return;
}
}
if (notfounds.size() > 0) {
element.defer = true;
element.unresolved = notfounds.toString();
return;
}
String action = po.is_new() ? "New" : "Update";
po.saveEx();
element.recordId = po.get_ID();
X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, po.get_TableName(), po.get_Table_ID());
logImportDetail(ctx, impDetail, 1, po.toString(), element.recordId, action);
if (I_AD_Window.Table_Name.equals(tableName) || I_AD_Process.Table_Name.equals(tableName) || I_AD_Role.Table_Name.equals(tableName) || I_AD_Form.Table_Name.equals(tableName) || I_C_DocType.Table_Name.equals(tableName) || I_AD_InfoWindow.Table_Name.equals(tableName))
element.requireRoleAccessUpdate = true;
}
Aggregations