Search in sources :

Example 6 with MProject

use of org.compiere.model.MProject in project adempiere by adempiere.

the class ImportEmployee method fillIdValues.

/**
     * Fill values and validate employee data
     * This method create the dependences for Race , Department , Job , Job Type
     * Job Education , Career Level , Employee Type and Skill Type
     * @param importEmployee
     * @param trxName
     */
private void fillIdValues(X_I_HR_Employee importEmployee, String trxName) {
    StringBuffer stringError = new StringBuffer("");
    Integer orgId = 0;
    if (importEmployee.getAD_Org_ID() > 0)
        orgId = importEmployee.getAD_Org_ID();
    if (orgId <= 0)
        orgId = getId(MOrg.Table_Name, MOrg.COLUMNNAME_Value + "=?", trxName, importEmployee.getOrgValue());
    if (orgId > 0)
        importEmployee.setAD_Org_ID(orgId);
    Integer partnerId = getId(MBPartner.Table_Name, MBPartner.COLUMNNAME_Value + "=?", trxName, importEmployee.getBPartnerValue());
    if (partnerId > 0)
        importEmployee.setC_BPartner_ID(partnerId);
    else if (isCreatedBusinessPartner()) {
        if (getBusinessPartnerGroupId() > 0) {
            MBPartner partner = createPartnerFromEmployeeData(importEmployee);
            partnerId = partner.get_ID();
            importEmployee.setC_BPartner_ID(partnerId);
        } else
            stringError.append(" @C_BP_Group_ID@ @NotFound@");
    }
    //Set Race
    MHRRace race = null;
    if (importEmployee.getHR_Race_ID() > 0)
        race = MHRRace.getById(getCtx(), importEmployee.getHR_Race_ID());
    if (race != null && race.getHR_Race_ID() < 0 && importEmployee.getRaceValue() != null)
        race = MHRRace.getByValue(getCtx(), importEmployee.getRaceValue());
    if (race == null || race.getHR_Race_ID() < 0) {
        if (importEmployee.getRaceValue() != null && importEmployee.getRaceName() != null) {
            race = new MHRRace(getCtx(), importEmployee.getRaceValue(), importEmployee.getRaceName(), trxName);
            race.saveEx();
        }
    }
    if (race != null && race.getHR_Race_ID() > 0)
        importEmployee.setHR_Race_ID(race.getHR_Race_ID());
    //Set Organization Trx
    MOrg orgTrx = null;
    if (importEmployee.getAD_OrgTrx_ID() > 0)
        orgTrx = MOrg.get(getCtx(), importEmployee.getAD_OrgTrx_ID());
    if (orgTrx == null && importEmployee.getOrgTrxValue() != null) {
        int orgTrxId = getId(MOrg.Table_Name, MOrg.COLUMNNAME_Value + "=?", trxName, importEmployee.getOrgTrxValue());
        orgTrx = MOrg.get(getCtx(), orgTrxId);
    }
    if (orgTrx != null && orgTrx.getAD_Org_ID() > 0)
        importEmployee.setAD_OrgTrx_ID(orgTrx.getAD_Org_ID());
    //Set Project
    MProject project = null;
    if (importEmployee.getC_Project_ID() > 0)
        project = MProject.getById(getCtx(), importEmployee.getC_Project_ID());
    if (project == null && importEmployee.getProjectValue() != null)
        project = MProject.getByValue(getCtx(), importEmployee.getProjectValue());
    if (project != null && project.getC_Project_ID() > 0)
        importEmployee.setC_Project_ID(project.getC_Project_ID());
    //Set Department
    MHRDepartment department = null;
    if (importEmployee.getHR_Department_ID() > 0)
        department = MHRDepartment.getById(getCtx(), importEmployee.getHR_Department_ID());
    if (department == null && importEmployee.getDepartmentValue() != null)
        department = MHRDepartment.getByValue(getCtx(), importEmployee.getDepartmentValue());
    if (department == null || department.getHR_Department_ID() < 0) {
        if (importEmployee.getDepartmentValue() != null && importEmployee.getDepartmentName() != null) {
            department = new MHRDepartment(getCtx(), importEmployee.getDepartmentValue(), importEmployee.getDepartmentName(), trxName);
            department.saveEx();
        }
    }
    if (department != null && department.getHR_Department_ID() > 0)
        importEmployee.setHR_Department_ID(department.getHR_Department_ID());
    //Set Job
    MHRJob job = null;
    if (importEmployee.getHR_Job_ID() > 0)
        job = MHRJob.getById(getCtx(), importEmployee.getHR_Job_ID());
    if (job == null && importEmployee.getJobValue() != null)
        job = MHRJob.getByValue(getCtx(), importEmployee.getJobValue());
    if (job == null || job.getHR_Job_ID() < 0) {
        if (importEmployee.getJobValue() != null && importEmployee.getJobName() != null) {
            job = new MHRJob(getCtx(), importEmployee.getJobValue(), importEmployee.getJobName(), trxName);
            job.saveEx();
        }
    }
    if (job != null && job.getHR_Job_ID() > 0)
        importEmployee.setHR_Job_ID(job.getHR_Job_ID());
    //Set Job Education
    MHRJobEducation jobEducation = null;
    if (importEmployee.getHR_JobEducation_ID() > 0)
        jobEducation = new MHRJobEducation(getCtx(), importEmployee.getHR_JobEducation_ID(), trxName);
    if (jobEducation == null && importEmployee.getJobEducationValue() != null)
        jobEducation = MHRJobEducation.getByValue(getCtx(), importEmployee.getJobEducationValue());
    if (jobEducation == null || jobEducation.getHR_JobEducation_ID() < 0) {
        if (importEmployee.getJobEducationValue() != null && importEmployee.getJobEducationName() != null) {
            jobEducation = new MHRJobEducation(getCtx(), importEmployee.getJobEducationValue(), importEmployee.getJobEducationName(), trxName);
            jobEducation.saveEx();
        }
    }
    if (jobEducation != null && jobEducation.getHR_JobEducation_ID() > 0)
        importEmployee.setHR_JobEducation_ID(jobEducation.getHR_JobEducation_ID());
    // Set Carrer Level
    MHRCareerLevel careerLevel = null;
    if (importEmployee.getHR_CareerLevel_ID() > 0)
        careerLevel = new MHRCareerLevel(getCtx(), importEmployee.getHR_CareerLevel_ID(), trxName);
    if (careerLevel == null && importEmployee.getCareerLevelValue() != null)
        careerLevel = MHRCareerLevel.getByValue(getCtx(), importEmployee.getCareerLevelValue());
    if (careerLevel == null || careerLevel.getHR_CareerLevel_ID() < 0) {
        if (importEmployee.getCareerLevelValue() != null && importEmployee.getCareerLevelName() != null) {
            careerLevel = new MHRCareerLevel(getCtx(), importEmployee.getCareerLevelValue(), importEmployee.getCareerLevelName(), trxName);
            careerLevel.saveEx();
        }
    }
    if (careerLevel != null && careerLevel.getHR_CareerLevel_ID() > 0)
        importEmployee.setHR_CareerLevel_ID(careerLevel.getHR_CareerLevel_ID());
    // Set Job Type
    MHRJobType jobType = null;
    if (importEmployee.getHR_JobType_ID() > 0)
        jobType = MHRJobType.getById(getCtx(), importEmployee.getHR_JobType_ID());
    if (jobType == null && importEmployee.getJobTypeValue() != null)
        jobType = MHRJobType.getByValue(getCtx(), importEmployee.getJobTypeValue());
    if (jobType == null || jobType.getHR_JobType_ID() < 0) {
        if (importEmployee.getJobTypeValue() != null && importEmployee.getJobTypeName() != null) {
            jobType = new MHRJobType(getCtx(), importEmployee.getJobTypeValue(), importEmployee.getJobTypeName(), trxName);
            jobType.saveEx();
        }
    }
    if (jobType != null && jobType.getHR_JobType_ID() > 0)
        importEmployee.setHR_JobType_ID(jobType.getHR_JobType_ID());
    // Set Payroll
    MHRPayroll payroll = null;
    if (importEmployee.getHR_Payroll_ID() > 0)
        payroll = MHRPayroll.getById(getCtx(), importEmployee.getHR_Job_ID());
    if (payroll == null && importEmployee.getPayrollValue() != null)
        payroll = MHRPayroll.getByValue(getCtx(), importEmployee.getPayrollValue());
    if (payroll != null && payroll.getHR_Payroll_ID() > 0)
        importEmployee.setHR_Payroll_ID(payroll.getHR_Payroll_ID());
    // Set Activity
    MActivity activity = null;
    if (importEmployee.getC_Activity_ID() > 0)
        activity = MActivity.getById(getCtx(), importEmployee.getC_Activity_ID());
    if (activity == null && importEmployee.getActivityValue() != null)
        activity = MActivity.getByValue(getCtx(), importEmployee.getActivityValue());
    if (activity != null && activity.getC_Activity_ID() > 0)
        importEmployee.setC_Activity_ID(activity.getC_Activity_ID());
    // Set Campaign
    MCampaign campaign = null;
    if (importEmployee.getC_Campaign_ID() > 0)
        campaign = MCampaign.getById(getCtx(), importEmployee.getC_Campaign_ID());
    if (campaign == null && importEmployee.getCampaignValue() != null)
        campaign = MCampaign.getByValue(getCtx(), importEmployee.getCampaignValue());
    if (campaign != null && campaign.getC_Campaign_ID() > 0)
        importEmployee.setC_Campaign_ID(campaign.getC_Campaign_ID());
    // Set Sales Region
    MSalesRegion salesRegion = null;
    if (importEmployee.getC_SalesRegion_ID() > 0)
        salesRegion = MSalesRegion.getById(getCtx(), importEmployee.getC_SalesRegion_ID());
    if (salesRegion == null && importEmployee.getSalesRegionValue() != null)
        salesRegion = MSalesRegion.getByValue(getCtx(), importEmployee.getSalesRegionValue());
    if (salesRegion != null && salesRegion.getC_SalesRegion_ID() > 0)
        importEmployee.setC_SalesRegion_ID(salesRegion.getC_SalesRegion_ID());
    // Set Work Group
    MHRWorkGroup workGroup = null;
    if (importEmployee.getHR_WorkGroup_ID() > 0)
        workGroup = MHRWorkGroup.getById(getCtx(), importEmployee.getHR_WorkGroup_ID());
    if (workGroup == null && importEmployee.getWorkGroupValue() != null)
        workGroup = MHRWorkGroup.getByValue(getCtx(), importEmployee.getWorkGroupValue());
    if (workGroup != null && workGroup.getHR_WorkGroup_ID() > 0)
        importEmployee.setHR_WorkGroup_ID(workGroup.getHR_WorkGroup_ID());
    // Set Shift Group
    MHRShiftGroup shiftGroup = null;
    if (importEmployee.getHR_ShiftGroup_ID() > 0)
        shiftGroup = MHRShiftGroup.getById(getCtx(), importEmployee.getHR_WorkGroup_ID());
    if (shiftGroup == null && importEmployee.getShiftGroupValue() != null)
        shiftGroup = MHRShiftGroup.getByValue(getCtx(), importEmployee.getWorkGroupValue());
    if (shiftGroup != null && shiftGroup.getHR_ShiftGroup_ID() > 0)
        importEmployee.setHR_ShiftGroup_ID(shiftGroup.getHR_ShiftGroup_ID());
    // Set Degree
    MHRDegree degree = null;
    if (importEmployee.getHR_Degree_ID() > 0)
        degree = MHRDegree.getById(getCtx(), importEmployee.getHR_Degree_ID());
    if (degree == null && importEmployee.getDegreeValue() != null)
        degree = MHRDegree.getByValue(getCtx(), importEmployee.getDegreeValue());
    if (degree == null || degree.getHR_Degree_ID() < 0) {
        if (importEmployee.getDegreeValue() != null && importEmployee.getDegreeName() != null) {
            degree = new MHRDegree(getCtx(), importEmployee.getDegreeValue(), importEmployee.getDegreeName(), trxName);
            degree.saveEx();
        }
    }
    //	Set it
    if (degree != null && degree.getHR_Degree_ID() > 0)
        importEmployee.setHR_Degree_ID(degree.getHR_Degree_ID());
    // Set Grade
    MHRGrade grade = null;
    if (importEmployee.getHR_Grade_ID() > 0)
        grade = MHRGrade.getById(getCtx(), importEmployee.getHR_Grade_ID());
    if (grade == null && importEmployee.getGradeValue() != null)
        grade = MHRGrade.getByValue(getCtx(), importEmployee.getGradeValue());
    if (grade == null || grade.getHR_Grade_ID() < 0) {
        if (importEmployee.getGradeValue() != null && importEmployee.getGradeName() != null) {
            grade = new MHRGrade(getCtx(), importEmployee.getGradeValue(), importEmployee.getGradeName(), trxName);
            grade.saveEx();
        }
    }
    if (grade != null && grade.getHR_Grade_ID() > 0)
        importEmployee.setHR_Grade_ID(grade.getHR_Grade_ID());
    //Set Designation
    MHRDesignation designation = null;
    if (importEmployee.getHR_Designation_ID() > 0)
        designation = MHRDesignation.getById(getCtx(), importEmployee.getHR_Designation_ID());
    if (designation == null && importEmployee.getDesignationValue() != null)
        designation = MHRDesignation.getByValue(getCtx(), importEmployee.getDesignationValue());
    if (designation != null && designation.getHR_Designation_ID() > 0)
        importEmployee.setHR_Designation_ID(designation.getHR_Designation_ID());
    //Set Salary Structure
    MHRSalaryStructure salaryStructure = null;
    if (importEmployee.getHR_SalaryRange_ID() > 0)
        salaryStructure = MHRSalaryStructure.getById(getCtx(), importEmployee.getHR_SalaryStructure_ID());
    if (salaryStructure == null && importEmployee.getSalaryStructureValue() != null)
        salaryStructure = MHRSalaryStructure.getByValue(getCtx(), importEmployee.getSalaryStructureValue());
    if (salaryStructure != null && salaryStructure.getHR_SalaryStructure_ID() > 0)
        importEmployee.setHR_SalaryRange_ID(salaryStructure.getHR_SalaryStructure_ID());
    //Set Salary Range
    MHRSalaryRange salaryRange = null;
    if (importEmployee.getHR_SalaryRange_ID() > 0)
        salaryRange = MHRSalaryRange.getById(getCtx(), importEmployee.getHR_SalaryRange_ID());
    if (salaryRange == null && importEmployee.getSalaryRangeValue() != null)
        salaryRange = MHRSalaryRange.getByValue(getCtx(), importEmployee.getSalaryRangeValue());
    if (salaryRange != null && salaryRange.getHR_SalaryRange_ID() > 0)
        importEmployee.setHR_SalaryRange_ID(salaryRange.getHR_SalaryRange_ID());
    // Set Employee Type
    MHREmployeeType employeeType = null;
    if (importEmployee.getHR_EmployeeType_ID() > 0)
        employeeType = MHREmployeeType.getById(getCtx(), importEmployee.getHR_EmployeeType_ID());
    if (employeeType == null && importEmployee.getEmployeeTypeValue() != null)
        employeeType = MHREmployeeType.getByValue(getCtx(), importEmployee.getEmployeeTypeValue());
    if (employeeType == null || employeeType.getHR_EmployeeType_ID() < 0) {
        if (importEmployee.getEmployeeTypeValue() != null && importEmployee.getEmployeeTypeName() != null && payroll != null && payroll.getHR_Payroll_ID() > 0) {
            employeeType = new MHREmployeeType(getCtx(), importEmployee.getEmployeeTypeValue(), importEmployee.getEmployeeTypeName(), MHREmployeeType.WAGELEVEL_Daily, payroll.getHR_Payroll_ID(), trxName);
            employeeType.saveEx();
        }
    }
    if (employeeType != null && employeeType.getHR_EmployeeType_ID() > 0)
        importEmployee.setHR_EmployeeType_ID(employeeType.getHR_EmployeeType_ID());
    // Set Skill Type
    MHRSkillType skillType = null;
    if (importEmployee.getHR_SkillType_ID() > 0)
        skillType = MHRSkillType.getById(getCtx(), importEmployee.getHR_SkillType_ID());
    if (skillType == null && importEmployee.getSkillTypeValue() != null)
        skillType = MHRSkillType.getByValue(getCtx(), importEmployee.getSkillTypeValue());
    if (skillType == null || skillType.getHR_SkillType_ID() < 0) {
        if (importEmployee.getSkillTypeValue() != null && importEmployee.getSkillTypeName() != null) {
            skillType = new MHRSkillType(getCtx(), importEmployee.getSkillTypeValue(), importEmployee.getSkillTypeName(), trxName);
            skillType.saveEx();
        }
    }
    if (skillType != null && skillType.getHR_SkillType_ID() > 0)
        importEmployee.setHR_SkillType_ID(skillType.getHR_SkillType_ID());
    if (importEmployee.getAD_Org_ID() <= 0)
        stringError.append(" @AD_Org_ID@ @IsMandatory@");
    if (importEmployee.getC_BPartner_ID() <= 0)
        stringError.append(" @C_BPartner_ID@ @IsMandatory@,");
    if (importEmployee.getHR_Department_ID() <= 0)
        stringError.append(" @HR_Department_ID@ @NotFound@,");
    if (importEmployee.getHR_Job_ID() <= 0)
        stringError.append(" @HR_Job_ID@ @NotFound@,");
    if (importEmployee.getStartDate() == null)
        stringError.append(" @StartDate@ @IsMandatory@ ");
    if (!stringError.toString().isEmpty() && stringError.toString().length() > 0) {
        importEmployee.setI_ErrorMsg(Msg.parseTranslation(getCtx(), stringError.toString()));
        importEmployee.saveEx();
    }
    importEmployee.saveEx();
}
Also used : MHRPayroll(org.eevolution.model.MHRPayroll) MHRGrade(org.eevolution.model.MHRGrade) MActivity(org.compiere.model.MActivity) MHRDepartment(org.eevolution.model.MHRDepartment) MHRDesignation(org.eevolution.model.MHRDesignation) MHRRace(org.eevolution.model.MHRRace) MProject(org.compiere.model.MProject) MHREmployeeType(org.eevolution.model.MHREmployeeType) MHRJob(org.eevolution.model.MHRJob) MSalesRegion(org.compiere.model.MSalesRegion) MCampaign(org.compiere.model.MCampaign) MBPartner(org.compiere.model.MBPartner) MHRSalaryRange(org.eevolution.model.MHRSalaryRange) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MHRShiftGroup(org.eevolution.model.MHRShiftGroup) MHRWorkGroup(org.eevolution.model.MHRWorkGroup) MHRDegree(org.eevolution.model.MHRDegree) MOrg(org.compiere.model.MOrg) MHRSalaryStructure(org.eevolution.model.MHRSalaryStructure) MHRJobEducation(org.eevolution.model.MHRJobEducation) MHRJobType(org.eevolution.model.MHRJobType) MHRSkillType(org.eevolution.model.MHRSkillType) MHRCareerLevel(org.eevolution.model.MHRCareerLevel)

Example 7 with MProject

use of org.compiere.model.MProject in project adempiere by adempiere.

the class ImportEmployeeAttributes method fillIdValues.

//	doIt
/**
     * Fill mandatory information
     *
     * @param importEmployeeAttribute
     */
private void fillIdValues(X_I_HR_Attribute importEmployeeAttribute) {
    StringBuilder messageError = new StringBuilder();
    importEmployeeAttribute.setI_ErrorMsg("");
    final String partnerQuery = "SELECT C_BPartner_ID FROM C_BPartner WHERE TRIM(Value) = TRIM(?)";
    int partnerId = DB.getSQLValue(null, partnerQuery, importEmployeeAttribute.getValue());
    if (partnerId < 0)
        messageError.append("@HR_Employee_ID@ @NotFound@");
    final String conceptQuery = "SELECT HR_Concept_ID FROM HR_Concept WHERE TRIM(Value) = TRIM(?)";
    int conceptId = DB.getSQLValue(importEmployeeAttribute.get_TrxName(), conceptQuery, importEmployeeAttribute.getConceptValue());
    if (conceptId < 0)
        messageError.append(", ").append("@HR_Concept_ID@ @NotFound@");
    if (importEmployeeAttribute.getValidFrom() == null)
        messageError.append(", ").append("@Invalid@ @ValidFrom@");
    if (messageError.length() > 0)
        setImportError(importEmployeeAttribute, messageError.toString()).saveEx(importEmployeeAttribute.get_TrxName());
    importEmployeeAttribute.setC_BPartner_ID(partnerId);
    importEmployeeAttribute.setHR_Concept_ID(conceptId);
    //	For Reference
    //Set Race
    MHRRace race = null;
    if (importEmployeeAttribute.getHR_Race_ID() > 0)
        race = MHRRace.getById(getCtx(), importEmployeeAttribute.getHR_Race_ID());
    if (race != null && race.getHR_Race_ID() < 0 && importEmployeeAttribute.getRaceValue() != null)
        race = MHRRace.getByValue(getCtx(), importEmployeeAttribute.getRaceValue());
    if (race != null && race.getHR_Race_ID() > 0)
        importEmployeeAttribute.setHR_Race_ID(race.getHR_Race_ID());
    //Set Organization Trx
    MOrg orgTrx = null;
    if (importEmployeeAttribute.getAD_OrgTrx_ID() > 0)
        orgTrx = MOrg.get(getCtx(), importEmployeeAttribute.getAD_OrgTrx_ID());
    if (orgTrx == null && importEmployeeAttribute.getOrgTrxValue() != null) {
        int orgTrxId = getId(MOrg.Table_Name, MOrg.COLUMNNAME_Value + "=?", get_TrxName(), importEmployeeAttribute.getOrgTrxValue());
        orgTrx = MOrg.get(getCtx(), orgTrxId);
    }
    if (orgTrx != null && orgTrx.getAD_Org_ID() > 0)
        importEmployeeAttribute.setAD_OrgTrx_ID(orgTrx.getAD_Org_ID());
    //Set Project
    MProject project = null;
    if (importEmployeeAttribute.getC_Project_ID() > 0)
        project = MProject.getById(getCtx(), importEmployeeAttribute.getC_Project_ID());
    if (project == null && importEmployeeAttribute.getProjectValue() != null)
        project = MProject.getByValue(getCtx(), importEmployeeAttribute.getProjectValue());
    if (project != null && project.getC_Project_ID() > 0)
        importEmployeeAttribute.setC_Project_ID(project.getC_Project_ID());
    //Set Department
    MHRDepartment department = null;
    if (importEmployeeAttribute.getHR_Department_ID() > 0)
        department = MHRDepartment.getById(getCtx(), importEmployeeAttribute.getHR_Department_ID());
    if (department == null && importEmployeeAttribute.getDepartmentValue() != null)
        department = MHRDepartment.getByValue(getCtx(), importEmployeeAttribute.getDepartmentValue());
    if (department != null && department.getHR_Department_ID() > 0)
        importEmployeeAttribute.setHR_Department_ID(department.getHR_Department_ID());
    //Set Job
    MHRJob job = null;
    if (importEmployeeAttribute.getHR_Job_ID() > 0)
        job = MHRJob.getById(getCtx(), importEmployeeAttribute.getHR_Job_ID());
    if (job == null && importEmployeeAttribute.getJobValue() != null)
        job = MHRJob.getByValue(getCtx(), importEmployeeAttribute.getJobValue());
    if (job != null && job.getHR_Job_ID() > 0)
        importEmployeeAttribute.setHR_Job_ID(job.getHR_Job_ID());
    //Set Job Education
    MHRJobEducation jobEducation = null;
    if (importEmployeeAttribute.getHR_JobEducation_ID() > 0)
        jobEducation = new MHRJobEducation(getCtx(), importEmployeeAttribute.getHR_JobEducation_ID(), importEmployeeAttribute.get_TrxName());
    if (jobEducation == null && importEmployeeAttribute.getJobEducationValue() != null)
        jobEducation = MHRJobEducation.getByValue(getCtx(), importEmployeeAttribute.getJobEducationValue());
    if (jobEducation != null && jobEducation.getHR_JobEducation_ID() > 0)
        importEmployeeAttribute.setHR_JobEducation_ID(jobEducation.getHR_JobEducation_ID());
    // Set Carrer Level
    MHRCareerLevel careerLevel = null;
    if (importEmployeeAttribute.getHR_CareerLevel_ID() > 0)
        careerLevel = new MHRCareerLevel(getCtx(), importEmployeeAttribute.getHR_CareerLevel_ID(), importEmployeeAttribute.get_TrxName());
    if (careerLevel == null && importEmployeeAttribute.getCareerLevelValue() != null)
        careerLevel = MHRCareerLevel.getByValue(getCtx(), importEmployeeAttribute.getCareerLevelValue());
    if (careerLevel != null && careerLevel.getHR_CareerLevel_ID() > 0)
        importEmployeeAttribute.setHR_CareerLevel_ID(careerLevel.getHR_CareerLevel_ID());
    // Set Job Type
    MHRJobType jobType = null;
    if (importEmployeeAttribute.getHR_JobType_ID() > 0)
        jobType = MHRJobType.getById(getCtx(), importEmployeeAttribute.getHR_JobType_ID());
    if (jobType == null && importEmployeeAttribute.getJobTypeValue() != null)
        jobType = MHRJobType.getByValue(getCtx(), importEmployeeAttribute.getJobTypeValue());
    if (jobType != null && jobType.getHR_JobType_ID() > 0)
        importEmployeeAttribute.setHR_JobType_ID(jobType.getHR_JobType_ID());
    // Set Payroll
    MHRPayroll payroll = null;
    if (importEmployeeAttribute.getHR_Payroll_ID() > 0)
        payroll = MHRPayroll.getById(getCtx(), importEmployeeAttribute.getHR_Job_ID());
    if (payroll == null && importEmployeeAttribute.getPayrollValue() != null)
        payroll = MHRPayroll.getByValue(getCtx(), importEmployeeAttribute.getPayrollValue());
    if (payroll != null && payroll.getHR_Payroll_ID() > 0)
        importEmployeeAttribute.setHR_Payroll_ID(payroll.getHR_Payroll_ID());
    // Set Activity
    MActivity activity = null;
    if (importEmployeeAttribute.getC_Activity_ID() > 0)
        activity = MActivity.getById(getCtx(), importEmployeeAttribute.getC_Activity_ID());
    if (activity == null && importEmployeeAttribute.getActivityValue() != null)
        activity = MActivity.getByValue(getCtx(), importEmployeeAttribute.getActivityValue());
    if (activity != null && activity.getC_Activity_ID() > 0)
        importEmployeeAttribute.setC_Activity_ID(activity.getC_Activity_ID());
    // Set Campaign
    MCampaign campaign = null;
    if (importEmployeeAttribute.getC_Campaign_ID() > 0)
        campaign = MCampaign.getById(getCtx(), importEmployeeAttribute.getC_Campaign_ID());
    if (campaign == null && importEmployeeAttribute.getCampaignValue() != null)
        campaign = MCampaign.getByValue(getCtx(), importEmployeeAttribute.getCampaignValue());
    if (campaign != null && campaign.getC_Campaign_ID() > 0)
        importEmployeeAttribute.setC_Campaign_ID(campaign.getC_Campaign_ID());
    // Set Work Group
    MHRWorkGroup workGroup = null;
    if (importEmployeeAttribute.getHR_WorkGroup_ID() > 0)
        workGroup = MHRWorkGroup.getById(getCtx(), importEmployeeAttribute.getHR_WorkGroup_ID());
    if (workGroup == null && importEmployeeAttribute.getWorkGroupValue() != null)
        workGroup = MHRWorkGroup.getByValue(getCtx(), importEmployeeAttribute.getWorkGroupValue());
    if (workGroup != null && workGroup.getHR_WorkGroup_ID() > 0)
        importEmployeeAttribute.setHR_WorkGroup_ID(workGroup.getHR_WorkGroup_ID());
    // Set Shift Group
    MHRShiftGroup shiftGroup = null;
    if (importEmployeeAttribute.getHR_ShiftGroup_ID() > 0)
        shiftGroup = MHRShiftGroup.getById(getCtx(), importEmployeeAttribute.getHR_WorkGroup_ID());
    if (shiftGroup == null && importEmployeeAttribute.getShiftGroupValue() != null)
        shiftGroup = MHRShiftGroup.getByValue(getCtx(), importEmployeeAttribute.getWorkGroupValue());
    if (shiftGroup != null && shiftGroup.getHR_ShiftGroup_ID() > 0)
        importEmployeeAttribute.setHR_ShiftGroup_ID(shiftGroup.getHR_ShiftGroup_ID());
    // Set Degree
    MHRDegree degree = null;
    if (importEmployeeAttribute.getHR_Degree_ID() > 0)
        degree = MHRDegree.getById(getCtx(), importEmployeeAttribute.getHR_Degree_ID());
    if (degree == null && importEmployeeAttribute.getDegreeValue() != null)
        degree = MHRDegree.getByValue(getCtx(), importEmployeeAttribute.getDegreeValue());
    //	Set it
    if (degree != null && degree.getHR_Degree_ID() > 0)
        importEmployeeAttribute.setHR_Degree_ID(degree.getHR_Degree_ID());
    // Set Grade
    MHRGrade grade = null;
    if (importEmployeeAttribute.getHR_Grade_ID() > 0)
        grade = MHRGrade.getById(getCtx(), importEmployeeAttribute.getHR_Grade_ID());
    if (grade == null && importEmployeeAttribute.getGradeValue() != null)
        grade = MHRGrade.getByValue(getCtx(), importEmployeeAttribute.getGradeValue());
    if (grade != null && grade.getHR_Grade_ID() > 0)
        importEmployeeAttribute.setHR_Grade_ID(grade.getHR_Grade_ID());
    //Set Designation
    MHRDesignation designation = null;
    if (importEmployeeAttribute.getHR_Designation_ID() > 0)
        designation = MHRDesignation.getById(getCtx(), importEmployeeAttribute.getHR_Designation_ID());
    if (designation == null && importEmployeeAttribute.getDesignationValue() != null)
        designation = MHRDesignation.getByValue(getCtx(), importEmployeeAttribute.getDesignationValue());
    if (designation != null && designation.getHR_Designation_ID() > 0)
        importEmployeeAttribute.setHR_Designation_ID(designation.getHR_Designation_ID());
    //Set Salary Structure
    MHRSalaryStructure salaryStructure = null;
    if (importEmployeeAttribute.getHR_SalaryRange_ID() > 0)
        salaryStructure = MHRSalaryStructure.getById(getCtx(), importEmployeeAttribute.getHR_SalaryStructure_ID());
    if (salaryStructure == null && importEmployeeAttribute.getSalaryStructureValue() != null)
        salaryStructure = MHRSalaryStructure.getByValue(getCtx(), importEmployeeAttribute.getSalaryStructureValue());
    if (salaryStructure != null && salaryStructure.getHR_SalaryStructure_ID() > 0)
        importEmployeeAttribute.setHR_SalaryRange_ID(salaryStructure.getHR_SalaryStructure_ID());
    //Set Salary Range
    MHRSalaryRange salaryRange = null;
    if (importEmployeeAttribute.getHR_SalaryRange_ID() > 0)
        salaryRange = MHRSalaryRange.getById(getCtx(), importEmployeeAttribute.getHR_SalaryRange_ID());
    if (salaryRange == null && importEmployeeAttribute.getSalaryRangeValue() != null)
        salaryRange = MHRSalaryRange.getByValue(getCtx(), importEmployeeAttribute.getSalaryRangeValue());
    if (salaryRange != null && salaryRange.getHR_SalaryRange_ID() > 0)
        importEmployeeAttribute.setHR_SalaryRange_ID(salaryRange.getHR_SalaryRange_ID());
    // Set Employee Type
    MHREmployeeType employeeType = null;
    if (importEmployeeAttribute.getHR_EmployeeType_ID() > 0)
        employeeType = MHREmployeeType.getById(getCtx(), importEmployeeAttribute.getHR_EmployeeType_ID());
    if (employeeType == null && importEmployeeAttribute.getEmployeeTypeValue() != null)
        employeeType = MHREmployeeType.getByValue(getCtx(), importEmployeeAttribute.getEmployeeTypeValue());
    if (employeeType != null && employeeType.getHR_EmployeeType_ID() > 0)
        importEmployeeAttribute.setHR_EmployeeType_ID(employeeType.getHR_EmployeeType_ID());
    // Set Skill Type
    MHRSkillType skillType = null;
    if (importEmployeeAttribute.getHR_SkillType_ID() > 0)
        skillType = MHRSkillType.getById(getCtx(), importEmployeeAttribute.getHR_SkillType_ID());
    if (skillType == null && importEmployeeAttribute.getSkillTypeValue() != null)
        skillType = MHRSkillType.getByValue(getCtx(), importEmployeeAttribute.getSkillTypeValue());
    if (skillType != null && skillType.getHR_SkillType_ID() > 0)
        importEmployeeAttribute.setHR_SkillType_ID(skillType.getHR_SkillType_ID());
    //	
    importEmployeeAttribute.saveEx();
}
Also used : MCampaign(org.compiere.model.MCampaign) MActivity(org.compiere.model.MActivity) MProject(org.compiere.model.MProject) MOrg(org.compiere.model.MOrg)

Example 8 with MProject

use of org.compiere.model.MProject in project adempiere by adempiere.

the class WBOMDrop method cmd_saveProject.

//	cmd_saveInvoice
/**
	 * 	Save to Project
	 *	@param C_Project_ID id
	 *	@return true if saved
	 */
private boolean cmd_saveProject(int C_Project_ID) {
    log.config("C_Project_ID=" + C_Project_ID);
    MProject project = new MProject(Env.getCtx(), C_Project_ID, null);
    if (project.get_ID() == 0) {
        log.log(Level.SEVERE, "Not found - C_Project_ID=" + C_Project_ID);
        return false;
    }
    int lineCount = 0;
    //	for all bom lines
    for (int i = 0; i < m_selectionList.size(); i++) {
        if (isSelectionSelected(m_selectionList.get(i))) {
            BigDecimal qty = m_qtyList.get(i).getValue();
            int M_Product_ID = m_productList.get(i).intValue();
            //	Create Line
            MProjectLine pl = new MProjectLine(project);
            pl.setM_Product_ID(M_Product_ID);
            pl.setPlannedQty(qty);
            if (pl.save())
                lineCount++;
            else
                log.log(Level.SEVERE, "Line not saved");
        }
    //	line selected
    }
    //	for all bom lines
    FDialog.info(-1, this, project.getName() + " " + Msg.translate(Env.getCtx(), "Inserted") + "=" + lineCount);
    log.config("#" + lineCount);
    return true;
}
Also used : BigDecimal(java.math.BigDecimal) MProject(org.compiere.model.MProject) MProjectLine(org.compiere.model.MProjectLine)

Example 9 with MProject

use of org.compiere.model.MProject in project adempiere by adempiere.

the class ProjectSetType method doIt.

//	prepare
/**
	 *  Perform process.
	 *  @return Message (clear text)
	 *  @throws Exception if not successful
	 */
protected String doIt() throws Exception {
    m_C_Project_ID = getRecord_ID();
    log.info("doIt - C_Project_ID=" + m_C_Project_ID + ", C_ProjectType_ID=" + m_C_ProjectType_ID);
    //
    MProject project = new MProject(getCtx(), m_C_Project_ID, get_TrxName());
    if (project.getC_Project_ID() == 0 || project.getC_Project_ID() != m_C_Project_ID)
        throw new IllegalArgumentException("Project not found C_Project_ID=" + m_C_Project_ID);
    if (project.getC_ProjectType_ID_Int() > 0)
        throw new IllegalArgumentException("Project already has Type (Cannot overwrite) " + project.getC_ProjectType_ID());
    //
    MProjectType type = new MProjectType(getCtx(), m_C_ProjectType_ID, get_TrxName());
    if (type.getC_ProjectType_ID() == 0 || type.getC_ProjectType_ID() != m_C_ProjectType_ID)
        throw new IllegalArgumentException("Project Type not found C_ProjectType_ID=" + m_C_ProjectType_ID);
    //	Set & Copy if Service
    project.setProjectType(type);
    if (!project.save())
        throw new Exception("@Error@");
    //
    return "@OK@";
}
Also used : MProjectType(org.compiere.model.MProjectType) MProject(org.compiere.model.MProject)

Example 10 with MProject

use of org.compiere.model.MProject in project adempiere by adempiere.

the class ProjectIssue method doIt.

//	prepare
/**
	 *  Perform process.
	 *  @return Message (clear text)
	 *  @throws Exception if not successful
	 */
protected String doIt() throws Exception {
    //	Check Parameter
    m_project = new MProject(getCtx(), m_C_Project_ID, get_TrxName());
    if (!(MProject.PROJECTCATEGORY_WorkOrderJob.equals(m_project.getProjectCategory()) || MProject.PROJECTCATEGORY_AssetProject.equals(m_project.getProjectCategory())))
        throw new IllegalArgumentException("Project not Work Order or Asset =" + m_project.getProjectCategory());
    log.info(m_project.toString());
    //
    if (m_M_InOut_ID != 0)
        return issueReceipt();
    if (m_S_TimeExpense_ID != 0)
        return issueExpense();
    if (m_M_Locator_ID == 0)
        throw new IllegalArgumentException("Locator missing");
    if (m_C_ProjectLine_ID != 0)
        return issueProjectLine();
    return issueInventory();
}
Also used : MProject(org.compiere.model.MProject)

Aggregations

MProject (org.compiere.model.MProject)18 MProjectLine (org.compiere.model.MProjectLine)8 BigDecimal (java.math.BigDecimal)6 MOrder (org.compiere.model.MOrder)3 MOrderLine (org.compiere.model.MOrderLine)3 MProduct (org.compiere.model.MProduct)3 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)2 MActivity (org.compiere.model.MActivity)2 MCampaign (org.compiere.model.MCampaign)2 MOrg (org.compiere.model.MOrg)2 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MAssetAddition (org.compiere.model.MAssetAddition)1 MBPartner (org.compiere.model.MBPartner)1 MCostDetail (org.compiere.model.MCostDetail)1 MProductCategory (org.compiere.model.MProductCategory)1 MProductPricing (org.compiere.model.MProductPricing)1 MProjectPhase (org.compiere.model.MProjectPhase)1 MProjectTask (org.compiere.model.MProjectTask)1 MProjectType (org.compiere.model.MProjectType)1