Search in sources :

Example 1 with X_I_Product_ASI

use of org.eevolution.model.X_I_Product_ASI in project adempiere by adempiere.

the class ImportProductASI method fillIDValues.

/**
	 * fill IDs values based on Search Key
	 * 
	 * @throws SQLException
	 */
private void fillIDValues() throws SQLException {
    for (X_I_Product_ASI ip_asi : getRecords(false, m_IsImportOnlyNoErrors)) {
        // Product
        int M_Product_ID = 0;
        if (ip_asi.getM_Product_ID() > 0)
            M_Product_ID = getID(MProduct.Table_Name, "M_Product_ID = ?", ip_asi.getM_Product_ID());
        if (M_Product_ID <= 0 && ip_asi.getProductValue() != null) {
            M_Product_ID = getID(MProduct.Table_Name, "Value = ?", ip_asi.getProductValue());
            ip_asi.setM_Product_ID(M_Product_ID);
        } else
            ip_asi.setM_Product_ID(M_Product_ID);
        // Attribute Set
        int M_AttributeSet_ID = 0;
        if (ip_asi.getM_AttributeSet_ID() > 0)
            M_AttributeSet_ID = getID(MAttributeSet.Table_Name, "M_AttributeSet_ID = ?", ip_asi.getM_AttributeSet_ID());
        if (M_AttributeSet_ID <= 0 && ip_asi.getAttributeSetName() != null) {
            M_AttributeSet_ID = getID(MAttributeSet.Table_Name, "Name = ?", ip_asi.getAttributeSetName());
            ip_asi.setM_AttributeSet_ID(M_AttributeSet_ID);
        } else
            ip_asi.setM_AttributeSet_ID(M_AttributeSet_ID);
        // Attribute
        int M_Attribute_ID = 0;
        if (ip_asi.getM_Attribute_ID() > 0)
            M_Attribute_ID = getID(MAttribute.Table_Name, "M_Attribute_ID = ?", ip_asi.getM_Attribute_ID());
        if (M_Attribute_ID <= 0 && ip_asi.getAttributeName() != null) {
            M_Attribute_ID = getID(MAttribute.Table_Name, "Name = ?", ip_asi.getAttributeName());
            ip_asi.setM_Attribute_ID(M_Attribute_ID);
        } else
            ip_asi.setM_Attribute_ID(M_Attribute_ID);
        if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(ip_asi.getAttributeValueType()) && M_Attribute_ID > 0) {
            MAttribute attribute = new MAttribute(getCtx(), M_Attribute_ID, get_TrxName());
        }
        // Attribute Set Instance
        int M_AttributeSetInstance_ID = 0;
        if (ip_asi.getM_AttributeSetInstance_ID() > 0)
            M_AttributeSetInstance_ID = getID(MAttributeSetInstance.Table_Name, "M_AttributeSetInstance_ID = ?", ip_asi.getM_AttributeSetInstance_ID());
        StringBuffer err = new StringBuffer("");
        if (ip_asi.getM_Product_ID() <= 0)
            err.append(" @M_Product_ID@ @NotFound@,");
        if (ip_asi.getAttributeSetName() == null)
            err.append(" @AttributeSetName@ @NotFound@,");
        if (ip_asi.getMandatoryType() == null)
            err.append(" @MandatoryType@ @NotFound@,");
        if (ip_asi.getAttributeName() == null)
            err.append(" @AttributeName@ @NotFound@,");
        if (ip_asi.getAttributeValueType() == null)
            err.append(" @AttributeValueType@ @NotFound@,");
        if (ip_asi.getAttributeValue() == null)
            err.append(" @AttributeValue@ @NotFound@,");
        if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(ip_asi.getAttributeValueType()) && ip_asi.getElementName() == null)
            err.append(" @ElementName@ @NotFound@,");
        if (err.toString() != null && err.toString().length() > 0) {
            notimported++;
            ip_asi.setI_ErrorMsg(Msg.parseTranslation(getCtx(), err.toString()));
        }
        ip_asi.saveEx();
        commitEx();
    }
}
Also used : X_I_Product_ASI(org.eevolution.model.X_I_Product_ASI) MAttribute(org.compiere.model.MAttribute)

Example 2 with X_I_Product_ASI

use of org.eevolution.model.X_I_Product_ASI in project adempiere by adempiere.

the class ImportProductASI method doIt.

// prepare
/**
	 * Perform process.
	 * 
	 * @return Message
	 * @throws Exception
	 */
protected String doIt() throws java.lang.Exception {
    if (m_DeleteOldImported) {
        int no = 0;
        for (X_I_Product_ASI ip_asi : getRecords(true, false)) {
            ip_asi.deleteEx(true);
            no++;
        }
        log.fine("Delete Old Impored =" + no);
    }
    fillIDValues();
    importRecords();
    return "Imported: " + imported + ", Not imported: " + notimported;
}
Also used : X_I_Product_ASI(org.eevolution.model.X_I_Product_ASI)

Example 3 with X_I_Product_ASI

use of org.eevolution.model.X_I_Product_ASI in project adempiere by adempiere.

the class ImportProductASI method importRecords.

// doIt
/**
	 * import records using I_Product_ASI table
	 * 
	 * @throws SQLException
	 */
private void importRecords() throws SQLException {
    for (X_I_Product_ASI ip_asi : getRecords(false, m_IsImportOnlyNoErrors)) {
        isImported = false;
        MAttributeInstance ai = importProductASI(ip_asi);
        if (ai != null || ai.get_ID() > 0)
            isImported = true;
        if (isImported) {
            ip_asi.setI_IsImported(true);
            ip_asi.setProcessed(true);
            ip_asi.setI_ErrorMsg("");
            ip_asi.saveEx();
            imported++;
            ip_asi.saveEx();
        } else {
            ip_asi.setI_IsImported(false);
            ip_asi.setProcessed(false);
            ip_asi.saveEx();
            notimported++;
        }
    }
}
Also used : X_I_Product_ASI(org.eevolution.model.X_I_Product_ASI) MAttributeInstance(org.compiere.model.MAttributeInstance)

Aggregations

X_I_Product_ASI (org.eevolution.model.X_I_Product_ASI)3 MAttribute (org.compiere.model.MAttribute)1 MAttributeInstance (org.compiere.model.MAttributeInstance)1