Search in sources :

Example 1 with X_I_ProductPlanning

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

the class ImportProductPlanning method importRecords.

// doIt
/**
	 * import record using X_I_ProductPlanning table
	 */
private void importRecords() {
    for (X_I_ProductPlanning ipp : getRecords(false, p_IsImportOnlyNoErrors)) {
        isImported = false;
        MPPProductPlanning pp = importProductPlanning(ipp);
        if (pp == null)
            isImported = false;
        if (isImported) {
            ipp.setPP_Product_Planning_ID(pp.getPP_Product_Planning_ID());
            ipp.setI_IsImported(true);
            ipp.setProcessed(true);
            ipp.setI_ErrorMsg("");
            ipp.saveEx();
            imported++;
        } else {
            ipp.setI_IsImported(false);
            ipp.setProcessed(true);
            ipp.saveEx();
            notimported++;
        }
    }
}
Also used : MPPProductPlanning(org.eevolution.model.MPPProductPlanning) X_I_ProductPlanning(org.eevolution.model.X_I_ProductPlanning)

Example 2 with X_I_ProductPlanning

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

the class ImportProductPlanning method fillIDValues.

/**
	 * fill IDs values based on Search Key
	 */
private void fillIDValues() {
    for (X_I_ProductPlanning ppi : getRecords(false, p_IsImportOnlyNoErrors)) {
        int AD_Org_ID = 0;
        if (ppi.getAD_Org_ID() > 0)
            AD_Org_ID = getID(MOrg.Table_Name, "AD_Org_ID = ?", ppi.getAD_Org_ID());
        if (AD_Org_ID <= 0 && ppi.getOrgValue() != null) {
            AD_Org_ID = getID(MOrg.Table_Name, "Value = ?", ppi.getOrgValue());
            ppi.setAD_Org_ID(AD_Org_ID);
        } else
            ppi.setAD_Org_ID(AD_Org_ID);
        int C_BPartner_ID = 0;
        if (ppi.getC_BPartner_ID() == 0)
            C_BPartner_ID = getID(I_C_BPartner.Table_Name, I_C_BPartner.COLUMNNAME_C_BPartner_ID + "=?", ppi.getC_BPartner_ID());
        if (C_BPartner_ID <= 0 && ppi.getBPartner_Value() != null) {
            C_BPartner_ID = getID(I_C_BPartner.Table_Name, I_C_BPartner.COLUMNNAME_Value + "=?", ppi.getBPartner_Value());
            ppi.setC_BPartner_ID(C_BPartner_ID);
        } else
            ppi.setC_BPartner_ID(C_BPartner_ID);
        // Product
        int M_Product_ID = 0;
        if (ppi.getM_Product_ID() > 0)
            M_Product_ID = getID(MProduct.Table_Name, "M_Product_ID = ?", ppi.getM_Product_ID());
        if (M_Product_ID <= 0 && ppi.getProductValue() != null) {
            M_Product_ID = getID(MProduct.Table_Name, "Value = ?", ppi.getProductValue());
            ppi.setM_Product_ID(M_Product_ID);
        } else
            ppi.setM_Product_ID(M_Product_ID);
        // Warehouse
        int M_Warehouse_ID = 0;
        if (ppi.getM_Warehouse_ID() > 0)
            M_Warehouse_ID = getID(MWarehouse.Table_Name, "M_Warehouse_ID = ?", ppi.getM_Warehouse_ID());
        if (M_Warehouse_ID <= 0 && ppi.getWarehouseValue() != null) {
            M_Warehouse_ID = getID(MWarehouse.Table_Name, "Value = ?", ppi.getWarehouseValue());
            ppi.setM_Warehouse_ID(M_Warehouse_ID);
        } else
            ppi.setM_Warehouse_ID(M_Warehouse_ID);
        int DD_NetworkDistribution_ID = 0;
        if (ppi.getDD_NetworkDistribution_ID() > 0)
            DD_NetworkDistribution_ID = getID(I_DD_NetworkDistribution.Table_Name, I_DD_NetworkDistribution.COLUMNNAME_DD_NetworkDistribution_ID + " = ?", ppi.getDD_NetworkDistribution_ID());
        if (DD_NetworkDistribution_ID <= 0 && ppi.getNetworkDistributionValue() != null) {
            DD_NetworkDistribution_ID = getID(I_DD_NetworkDistribution.Table_Name, I_DD_NetworkDistribution.COLUMNNAME_Value + "= ?", ppi.getNetworkDistributionValue());
            ppi.setDD_NetworkDistribution_ID(DD_NetworkDistribution_ID);
        } else
            ppi.setDD_NetworkDistribution_ID(DD_NetworkDistribution_ID);
        int PP_Product_BOM_ID = 0;
        if (ppi.getPP_Product_BOM_ID() > 0)
            PP_Product_BOM_ID = getID(I_PP_Product_BOM.Table_Name, I_PP_Product_BOM.COLUMNNAME_PP_Product_BOM_ID + "= ?", ppi.getPP_Product_BOM_ID());
        if (PP_Product_BOM_ID <= 0 && ppi.getProduct_BOM_Value() != null) {
            PP_Product_BOM_ID = getID(I_PP_Product_BOM.Table_Name, I_PP_Product_BOM.COLUMNNAME_Value + "= ?", ppi.getProduct_BOM_Value());
            ppi.setPP_Product_BOM_ID(PP_Product_BOM_ID);
        } else
            ppi.setPP_Product_BOM_ID(PP_Product_BOM_ID);
        int S_Resource_ID = 0;
        if (ppi.getS_Resource_ID() > 0)
            S_Resource_ID = getID(I_S_Resource.Table_Name, I_S_Resource.COLUMNNAME_S_Resource_ID + "= ?", ppi.getS_Resource_ID());
        if (S_Resource_ID <= 0 && ppi.getResourceValue() != null) {
            S_Resource_ID = getID(I_S_Resource.Table_Name, I_S_Resource.COLUMNNAME_Value + "=? AND " + I_S_Resource.COLUMNNAME_ManufacturingResourceType + "=?", ppi.getResourceValue(), X_S_Resource.MANUFACTURINGRESOURCETYPE_Plant);
            ppi.setS_Resource_ID(S_Resource_ID);
        } else
            ppi.setS_Resource_ID(S_Resource_ID);
        ppi.saveEx();
        StringBuffer err = new StringBuffer("");
        if (ppi.getAD_Org_ID() <= 0)
            err.append(" @AD_Org_ID@ @NotFound@,");
        if (ppi.getM_Product_ID() <= 0)
            err.append(" @M_Product_ID@ @NotFound@,");
        if (err.toString() != null && err.toString().length() > 0) {
            notimported++;
            ppi.setI_ErrorMsg(Msg.parseTranslation(getCtx(), err.toString()));
            ppi.saveEx();
        }
    }
}
Also used : X_I_ProductPlanning(org.eevolution.model.X_I_ProductPlanning)

Example 3 with X_I_ProductPlanning

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

the class ImportProductPlanning method doIt.

// prepare
/**
	 * Perform process.
	 * 
	 * @return Message
	 * @throws Exception
	 */
protected String doIt() throws java.lang.Exception {
    if (p_DeleteOldImported) {
        int no = 0;
        for (X_I_ProductPlanning ipp : getRecords(true, false)) {
            ipp.deleteEx(true);
            no++;
        }
        log.fine("Delete Old Impored =" + no);
    }
    // fill IDs using Search Key
    fillIDValues();
    // import record
    importRecords();
    return "Imported: " + imported + ", Not imported: " + notimported;
//
}
Also used : X_I_ProductPlanning(org.eevolution.model.X_I_ProductPlanning)

Aggregations

X_I_ProductPlanning (org.eevolution.model.X_I_ProductPlanning)3 MPPProductPlanning (org.eevolution.model.MPPProductPlanning)1