Search in sources :

Example 31 with AdempiereUserError

use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.

the class WebProjectDeploy method doIt.

//	prepare
/**
	 * 	Process
	 *	@return info
	 *	@throws Exception
	 */
protected String doIt() throws Exception {
    org.compiere.cm.CacheHandler thisHandler = new org.compiere.cm.CacheHandler(org.compiere.cm.CacheHandler.convertJNPURLToCacheURL(getCtx().getProperty("java.naming.provider.url")), log, getCtx(), get_TrxName());
    log.info("CM_WebProject_ID=" + p_CM_WebProject_ID);
    m_project = new MWebProject(getCtx(), p_CM_WebProject_ID, get_TrxName());
    if (m_project.get_ID() != p_CM_WebProject_ID)
        throw new AdempiereUserError("@NotFound@ @CM_WebProject_ID@ " + p_CM_WebProject_ID);
    //	Deploy Media
    MMedia[] media = MMedia.getMedia(m_project);
    MMediaServer[] mserver = MMediaServer.getMediaServer(m_project);
    for (int i = 0; i < mserver.length; i++) mserver[i].deploy(media);
    //	Stage
    MCStage[] stages = MCStage.getStages(m_project);
    for (int i = 0; i < stages.length; i++) m_map.put(new Integer(stages[i].getCM_CStage_ID()), stages[i]);
    //	Copy Stage Tree
    MTree treeS = new MTree(getCtx(), m_project.getAD_TreeCMS_ID(), false, false, get_TrxName());
    MTreeNode root = treeS.getRoot();
    copyStage(root, "/");
    //	Delete Inactive Containers
    MContainer[] containers = MContainer.getContainers(m_project);
    for (int i = 0; i < containers.length; i++) {
        MContainer container = containers[i];
        if (!m_idList.contains(new Integer(container.getCM_Container_ID()))) {
            String name = container.getName();
            if (container.delete(true))
                log.fine("Deleted: " + name);
            else //	e.g. was referenced
            {
                log.warning("Failed Delete: " + name);
                addLog(0, null, null, "@Error@ @Delete@: " + name);
            }
        }
        // Remove Container from cache
        thisHandler.cleanContainer(container.get_ID());
    }
    //	Delete Inactive
    //	Sync Stage & Container Tree
    MTree_NodeCMS[] nodesCMS = MTree_NodeCMS.getTree(getCtx(), m_project.getAD_TreeCMS_ID(), get_TrxName());
    MTree_NodeCMC[] nodesCMC = MTree_NodeCMC.getTree(getCtx(), m_project.getAD_TreeCMC_ID(), get_TrxName());
    for (int s = 0; s < nodesCMS.length; s++) {
        MTree_NodeCMS nodeCMS = nodesCMS[s];
        int Node_ID = nodeCMS.getNode_ID();
        for (int c = 0; c < nodesCMC.length; c++) {
            MTree_NodeCMC nodeCMC = nodesCMC[c];
            if (nodeCMC.getNode_ID() == Node_ID) {
                //if (nodeCMS.getParent_ID()!=0) 
                nodeCMC.setParent_ID(nodeCMS.getParent_ID());
                nodeCMC.setSeqNo(nodeCMS.getSeqNo());
                nodeCMC.saveEx();
                break;
            }
        }
    }
    //	for all stage nodes
    // Clean ContainerTree Cache
    thisHandler.cleanContainerTree(p_CM_WebProject_ID);
    return "@Copied@ @CM_Container_ID@ #" + m_idList.size();
}
Also used : MTree_NodeCMS(org.compiere.model.MTree_NodeCMS) MTreeNode(org.compiere.model.MTreeNode) AdempiereUserError(org.compiere.util.AdempiereUserError) MMedia(org.compiere.model.MMedia) MWebProject(org.compiere.model.MWebProject) MTree(org.compiere.model.MTree) MTree_NodeCMC(org.compiere.model.MTree_NodeCMC) MCStage(org.compiere.model.MCStage) MMediaServer(org.compiere.model.MMediaServer) MContainer(org.compiere.model.MContainer)

Example 32 with AdempiereUserError

use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.

the class FinReport method doIt.

//	setPeriods
/**************************************************************************
	 *  Perform process.
	 *  @return Message to be translated
	 *  @throws Exception
	 */
protected String doIt() throws Exception {
    log.info("AD_PInstance_ID=" + getAD_PInstance_ID());
    if (p_PA_ReportCube_ID > 0) {
        MReportCube cube = new MReportCube(getCtx(), p_PA_ReportCube_ID, get_TrxName());
        String result = cube.update(false, false);
        log.log(Level.FINE, result);
    }
    //	** Create Temporary and empty Report Lines from PA_ReportLine
    //	- AD_PInstance_ID, PA_ReportLine_ID, 0, 0
    int PA_ReportLineSet_ID = m_report.getLineSet().getPA_ReportLineSet_ID();
    StringBuffer sql = new StringBuffer("INSERT INTO T_Report " + "(AD_PInstance_ID, PA_ReportLine_ID, Record_ID,Fact_Acct_ID, SeqNo,LevelNo, Name,Description,TabLevel, ReportLineStyle, FixedPercentage) " + "SELECT ").append(getAD_PInstance_ID()).append(", PA_ReportLine_ID, 0,0, SeqNo,0, Name,Description,TabLevel,ReportLineStyle,FixedPercentage " + "FROM PA_ReportLine " + "WHERE IsActive='Y' AND PA_ReportLineSet_ID=").append(PA_ReportLineSet_ID);
    int no = DB.executeUpdate(sql.toString(), get_TrxName());
    log.fine("Report Lines = " + no);
    //	** Get Data	** Segment Values
    m_columns = m_report.getColumnSet().getColumns();
    if (m_columns.length == 0)
        throw new AdempiereUserError("@No@ @PA_ReportColumn_ID@");
    m_lines = m_report.getLineSet().getLiness();
    if (m_lines.length == 0)
        throw new AdempiereUserError("@No@ @PA_ReportLine_ID@");
    //	for all lines
    for (int line = 0; line < m_lines.length; line++) {
        //	Line Segment Value (i.e. not calculation)
        if (m_lines[line].isLineTypeSegmentValue())
            insertLine(line);
    }
    //	for all lines
    insertLineDetail();
    doCalculations();
    deleteUnprintedLines();
    scaleResults();
    //	Create Report
    if (Ini.isClient())
        getProcessInfo().setTransientObject(getPrintFormat());
    else
        getProcessInfo().setSerializableObject(getPrintFormat());
    MPrintFormat pf = getPrintFormat();
    log.fine((System.currentTimeMillis() - m_start) + " ms");
    return "";
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) AdempiereUserError(org.compiere.util.AdempiereUserError) MReportCube(org.compiere.model.MReportCube)

Example 33 with AdempiereUserError

use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.

the class WindowCopy method doIt.

//	prepare
/**
	 * 	Process
	 *	@return message
	 *	@throws Exception
	 */
protected String doIt() throws Exception {
    log.info("doIt - To AD_Window_ID=" + p_AD_WindowTo_ID + ", From=" + p_AD_WindowFrom_ID);
    MWindow from = new MWindow(getCtx(), p_AD_WindowFrom_ID, get_TrxName());
    if (from.get_ID() == 0)
        throw new AdempiereUserError("@NotFound@ (from->) @AD_Window_ID@");
    MWindow to = new MWindow(getCtx(), p_AD_WindowTo_ID, get_TrxName());
    if (to.get_ID() == 0)
        throw new AdempiereUserError("@NotFound@ (to<-) @AD_Window_ID@");
    int tabCount = 0;
    int fieldCount = 0;
    MTab[] oldTabs = from.getTabs(false, get_TrxName());
    for (int i = 0; i < oldTabs.length; i++) {
        MTab oldTab = oldTabs[i];
        MTab newTab = new MTab(to, oldTab);
        if (newTab.save()) {
            tabCount++;
            //	Copy Fields
            MField[] oldFields = oldTab.getFields(false, get_TrxName());
            for (int j = 0; j < oldFields.length; j++) {
                MField oldField = oldFields[j];
                MField newField = new MField(newTab, oldField);
                if (newField.save())
                    fieldCount++;
                else
                    throw new AdempiereUserError("@Error@ @AD_Field_ID@");
            }
        } else
            throw new AdempiereUserError("@Error@ @AD_Tab_ID@");
    }
    return "@Copied@ #" + tabCount + "/" + fieldCount;
}
Also used : AdempiereUserError(org.compiere.util.AdempiereUserError) MTab(org.compiere.model.MTab) MWindow(org.compiere.model.MWindow) MField(org.compiere.model.MField)

Example 34 with AdempiereUserError

use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.

the class SLAGoalProcess method doIt.

//	prepare
/**
	 * 	Process
	 *	@return info
	 *	@throws Exception
	 */
protected String doIt() throws Exception {
    log.info("PA_SLA_Goal_ID=" + p_PA_SLA_Goal_ID);
    MSLAGoal goal = new MSLAGoal(getCtx(), p_PA_SLA_Goal_ID, get_TrxName());
    if (goal.get_ID() == 0)
        throw new AdempiereUserError("@PA_SLA_Goal_ID@ " + p_PA_SLA_Goal_ID);
    MSLACriteria criteria = MSLACriteria.get(getCtx(), goal.getPA_SLA_Criteria_ID(), get_TrxName());
    if (criteria.get_ID() == 0)
        throw new AdempiereUserError("@PA_SLA_Criteria_ID@ " + goal.getPA_SLA_Criteria_ID());
    SLACriteria pgm = criteria.newInstance();
    int no = pgm.createMeasures(goal);
    //
    goal.setMeasureActual(pgm.calculateMeasure(goal));
    goal.setDateLastRun(new Timestamp(System.currentTimeMillis()));
    goal.saveEx();
    //
    return "@Created@ " + no + " - @MeasureActual@=" + goal.getMeasureActual();
}
Also used : MSLACriteria(org.compiere.model.MSLACriteria) AdempiereUserError(org.compiere.util.AdempiereUserError) MSLAGoal(org.compiere.model.MSLAGoal) MSLACriteria(org.compiere.model.MSLACriteria) Timestamp(java.sql.Timestamp)

Example 35 with AdempiereUserError

use of org.compiere.util.AdempiereUserError in project adempiere by adempiere.

the class MovementGenerate method doIt.

//	prepare
/**
	 * 	Generate Movements
	 *	@return info
	 *	@throws Exception
	 */
protected String doIt() throws Exception {
    log.info("Selection=" + p_Selection + ", M_Warehouse_ID=" + p_M_Warehouse_ID + ", C_BPartner_ID=" + p_C_BPartner_ID + ", Consolidate=" + p_ConsolidateDocument + ", IsUnconfirmed=" + p_IsUnconfirmedInOut + ", Movement=" + m_movementDate);
    if (p_M_Warehouse_ID == 0)
        throw new AdempiereUserError("@NotFound@ @M_Warehouse_ID@");
    if (p_Selection) {
        m_sql = "SELECT DD_Order.* FROM DD_Order, T_Selection " + "WHERE DD_Order.DocStatus='CO' AND DD_Order.AD_Client_ID=? " + "AND DD_Order.DD_Order_ID = T_Selection.T_Selection_ID " + "AND T_Selection.AD_PInstance_ID=? ";
    } else {
        m_sql = "SELECT * FROM DD_Order o " + "WHERE DocStatus='CO' " + //	No Offer,POS
        " AND o.C_DocType_ID IN (SELECT C_DocType_ID FROM C_DocType " + "WHERE DocBaseType='DOO')" + "	AND o.IsDropShip='N'" + //	No Manual
        " AND o.DeliveryRule<>'M'" + //	Open Order Lines with Warehouse
        " AND EXISTS (SELECT 1 FROM DD_OrderLine ol " + " WHERE ? IN (SELECT l.M_Warehouse_ID FROM M_Locator l WHERE l.M_Locator_ID=ol.M_Locator_ID) ";
        if (p_DatePromised != null)
            //	#2
            m_sql += " AND TRUNC(ol.DatePromised)<=?";
        m_sql += " AND o.DD_Order_ID=ol.DD_Order_ID AND ol.QtyOrdered<>ol.QtyIntransit)";
        //
        if (p_C_BPartner_ID != 0)
            //	#3
            m_sql += " AND o.C_BPartner_ID=?";
        m_sql += " ORDER BY M_Warehouse_ID, PriorityRule, M_Shipper_ID, C_BPartner_ID, C_BPartner_Location_ID, DD_Order_ID";
    }
    //	m_sql += " FOR UPDATE";
    PreparedStatement pstmt = null;
    try {
        pstmt = DB.prepareStatement(m_sql, get_TrxName());
        int index = 1;
        if (p_Selection) {
            pstmt.setInt(index++, Env.getAD_Client_ID(getCtx()));
            pstmt.setInt(index++, getAD_PInstance_ID());
        } else {
            pstmt.setInt(index++, p_M_Warehouse_ID);
            if (p_DatePromised != null)
                pstmt.setTimestamp(index++, p_DatePromised);
            if (p_C_BPartner_ID != 0)
                pstmt.setInt(index++, p_C_BPartner_ID);
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, m_sql, e);
    }
    return generate(pstmt);
}
Also used : AdempiereUserError(org.compiere.util.AdempiereUserError) PreparedStatement(java.sql.PreparedStatement) AdempiereException(org.adempiere.exceptions.AdempiereException)

Aggregations

AdempiereUserError (org.compiere.util.AdempiereUserError)62 PreparedStatement (java.sql.PreparedStatement)9 BigDecimal (java.math.BigDecimal)8 Timestamp (java.sql.Timestamp)8 AdempiereSystemError (org.compiere.util.AdempiereSystemError)8 ResultSet (java.sql.ResultSet)7 MBPartner (org.compiere.model.MBPartner)7 MClient (org.compiere.model.MClient)5 MWarehouse (org.compiere.model.MWarehouse)5 MProduct (org.compiere.model.MProduct)4 ValueNamePair (org.compiere.util.ValueNamePair)4 MUser (org.compiere.model.MUser)3 X_T_Replenish (org.compiere.model.X_T_Replenish)3 MPrintFormat (org.compiere.print.MPrintFormat)3 File (java.io.File)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 MAcctSchema (org.compiere.model.MAcctSchema)2 MBPartnerLocation (org.compiere.model.MBPartnerLocation)2 MColumn (org.compiere.model.MColumn)2 MCommission (org.compiere.model.MCommission)2