开发HRM项目的步骤:

1:首先保留HRM项目中的两张表(Employee,Position)把这两张表中的数据内容复制到Operator-Portlet这个项目中,这两张表的service.xml配置是:

<!-- Position -->
<entity name="Position" local-service="true" remote-service="false">
<column name="positionId" type="long" primary="true" />
<column name="companyId" type="long"/>
<column name="departmentId" type="long" />
<column name="position" type="String" />
<column name="positionLevel" type="String" />
<column name="upPosition" type="String" />
<column name="positionIndex" type="String" />
<column name="description" type="String" />
<finder name="CompanyId" return-type="Collection">
<finder-column name="companyId"/>
</finder>
</entity>
<!-- Employee -->
<entity name="Employee" local-service="true" remote-service="false">
<column name="employeeId" type="long" primary="true" />
<column name="companyId" type="long" />
<column name="operatorId" type="long" /><!-- 用户Id -->
<column name="departmentId" type="long" />
<column name="departmentName" type="String" />
<column name="employeeNo" type="String" />
<column name="employeeName" type="String" />
<column name="employeeSex" type="String" />
<column name="employeeAge" type="int" />
<column name="identityCard" type="String" />
<column name="birthDate" type="Date" />
<column name="nation" type="String" />
<column name="positionId" type="long" />
<column name="positionName" type="String" />
<column name="category" type="String" />
<column name="employeeType" type="String" />
<column name="photoId" type="long" />
<column name="policitalStatus" type="String" />
<column name="isMarry" type="String" />
<column name="homeAddress" type="String" />
<column name="archivesAddress" type="String" />
<column name="workAddress" type="String" />
<column name="mobilePhone" type="String" />
<column name="workPhone" type="String" />
<column name="email" type="String" />
<column name="QQ" type="String" />
<column name="MSN" type="String" />
<column name="wechart" type="String" /><!-- 微信 -->
<column name="microblog" type="String" />
<column name="interest" type="String" />
<column name="homePhone" type="String" />
<column name="emergencyPhone" type="String" />
<column name="internshipStart" type="Date" />
<column name="internshipEnd" type="Date" />
<column name="educationlevel" type="String" />
<column name="degree" type="String" />
<column name="graduatedUniversity" type="String" />
<column name="specialty" type="String" />
<column name="graduatedDate" type="Date" />
<column name="householdRegister" type="String" />
<column name="technicalTitle" type="String" />
<column name="contractStart" type="Date" />
<column name="contractEnd" type="Date" />
<column name="employeeStatus" type="String" />
<column name="dimissionType" type="String" />
<column name="onTrialDate" type="Date" />
<column name="offTrialDate" type="Date" />
<column name="entryDate" type="Date" />
<column name="dimissionDate" type="Date" />
<column name="dimissionReason" type="String" />
<column name="recruitmentResource" type="String" />
<column name="wageAccount" type="String" />
<column name="healthCareAccount" type="String" />
<column name="accumulationFundAccount" type="String" />
<column name="unemploymentInsurance" type="String" />
<column name="socialInsurance" type="String" />
<column name="endowmentInsurance" type="String" />
<column name="zodiac" type="String" />
<column name="constellation" type="String" /> <column name="createDate" type="Date" />
<column name="createUserId" type="long" /> <column name="strField1" type="String" />
<column name="strField2" type="String" />
<column name="strField3" type="String" />
<column name="strField4" type="String" />
<column name="strField5" type="String" />
<column name="strField6" type="String" />
<column name="strField7" type="String" />
<column name="strField8" type="String" />
<column name="textareaField1" type="String" />
<column name="textareaField2" type="String" />
<column name="textareaField3" type="String" />
<column name="textareaField4" type="String" />
<column name="floatField1" type="double" />
<column name="floatField2" type="double" />
<column name="floatField3" type="double" />
<column name="floatField4" type="double" />
<column name="dateField1" type="Date" />
<column name="dateField2" type="Date" />
<column name="dateField3" type="Date" />
<column name="dateField4" type="Date" /> <order by="desc">
<order-column name="createDate" />
</order>
<finder name="CompanyId" return-type="Collection">
<finder-column name="companyId" />
</finder>
<finder name="DepartmentId" return-type="Collection">
<finder-column name="departmentId" />
</finder>
<finder name="PositionId" return-type="Collection">
<finder-column name="positionId"/>
</finder>
</entity>

上述的finder标签会生成相应的方法。

2:需要写一个动态获取数据库表中的数据(和数据库表中的字段的名称),把这个类下载Operator-Portlet这个项目中的base包下。这个类的名称为DynamicPackageEntity.

package com.ebizwindow.operator.portlet.base;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import javax.portlet.PortletPreferences;
import javax.portlet.PortletRequest; import com.ebizwindow.crm.model.CompanyColumnDefinition;
import com.ebizwindow.crm.service.CompanyColumnDefinitionLocalServiceUtil;
import com.ebizwindow.operator.constants.TableConst;
import com.ebizwindow.operator.model.Department;
import com.ebizwindow.operator.model.Employee;
import com.ebizwindow.operator.model.Position;
import com.ebizwindow.operator.service.DepartmentLocalServiceUtil;
import com.ebizwindow.operator.service.EmployeeLocalServiceUtil;
import com.ebizwindow.operator.service.PositionLocalServiceUtil;
import com.ebizwindow.operator.utils.DateUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.User;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.util.PortalUtil; public class DynamicPackageEntity { /**
* 动态获取(职位)的值
* @param portletRequest
* @param positionId
* @return
* @throws PortalException
* @throws SystemException
*/ public static Map<String, String> getPositionValue(
PortletRequest portletRequest, Long positionId)
throws PortalException, SystemException {
Map<String, String> positionValue = null;
Long companyId = PortalUtil.getCompanyId(portletRequest);
if (positionId > 0) {
Position position = PositionLocalServiceUtil
.getPosition(positionId);
if (position != null) {
List<CompanyColumnDefinition> companyColumns =
CompanyColumnDefinitionLocalServiceUtil
.searchByTableName(companyId, TableConst.CRM_Position,
true);
positionValue = new HashMap<String, String>();
for(CompanyColumnDefinition companyColumnDefinition : companyColumns){
String columnName = companyColumnDefinition.getColumnName();
if(columnName.equals("departmentId")){
long departmentId = position.getDepartmentId();
Department department = null;
if (departmentId > 0) {
department = DepartmentLocalServiceUtil.getDepartment(departmentId);
}
positionValue.put(columnName, department != null ? department.getDepartmentName() : StringPool.BLANK);
} else if(columnName.equals("position")){
positionValue.put(columnName, position.getPosition());
} else if(columnName.equals("positionLevel")){
positionValue.put(columnName, position.getPositionLevel());
} else if(columnName.equals("upPosition")){
positionValue.put(columnName, position.getUpPosition());
} else if(columnName.equals("positionIndex")){
positionValue.put(columnName, position.getPositionIndex());
} else if(columnName.equals("description")){
positionValue.put(columnName, position.getDescription());
}
}
}
}
return positionValue;
} /**
* 动态获取(员工)的值
* @param portletRequest
* @param employeeId
* @return
* @throws PortalException
* @throws SystemException
*/
public static Map<String, String> getEmployeeValue(PortletRequest portletRequest, Long employeeId)
throws PortalException, SystemException { Map<String, String> entityValueMap = null;
long companyId = PortalUtil.getCompanyId(portletRequest);
if (employeeId > 0){
Employee employee = EmployeeLocalServiceUtil.getEmployee(employeeId);
if (employee != null){
List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil
.searchByTableName(companyId, TableConst.CRM_Employee, true);
entityValueMap = new HashMap<String, String>();
for (CompanyColumnDefinition companyColumn : companyColumns) {
String columnName = companyColumn.getColumnName();
if (columnName.equals("employeeName")) {
entityValueMap.put(columnName, employee.getEmployeeName());
} else if (columnName.equals("employeeNo")) {
entityValueMap.put(columnName, employee.getEmployeeNo());
} else if (columnName.equals("employeeAge")) {
entityValueMap.put(columnName, employee.getEmployeeAge() != 0
? String.valueOf(employee.getEmployeeAge()) : "");
} else if (columnName.equals("employeeSex")) {
entityValueMap.put(columnName, employee.getEmployeeSex());
} else if (columnName.equals("identityCard")) {
entityValueMap.put(columnName, employee.getIdentityCard());
} else if (columnName.equals("nation")) {
entityValueMap.put(columnName, employee.getNation());
} else if (columnName.equals("category")) {
entityValueMap.put(columnName, employee.getCategory());
} else if (columnName.equals("policitalStatus")) {
entityValueMap.put(columnName, employee.getPolicitalStatus());
} else if (columnName.equals("isMarry")) {
entityValueMap.put(columnName, employee.getIsMarry());
} else if (columnName.equals("employeeType")) {
entityValueMap.put(columnName, employee.getEmployeeType());
} else if (columnName.equals("mobilePhone")) {
entityValueMap.put(columnName, employee.getMobilePhone());
} else if (columnName.equals("workPhone")) {
entityValueMap.put(columnName, employee.getWorkPhone());
} else if (columnName.equals("email")) {
entityValueMap.put(columnName, employee.getEmail());
} else if (columnName.equals("QQ")) {
entityValueMap.put(columnName, employee.getQQ());
} else if (columnName.equals("MSN")) {
entityValueMap.put(columnName, employee.getMSN());
} else if (columnName.equals("zodiac")) {
entityValueMap.put(columnName, employee.getZodiac());
} else if (columnName.equals("constellation")) {
entityValueMap.put(columnName, employee.getConstellation());
} else if (columnName.equals("microblog")) {
entityValueMap.put(columnName, employee.getMicroblog());
} else if (columnName.equals("interest")) {
entityValueMap.put(columnName, employee.getInterest());
} else if (columnName.equals("homePhone")) {
entityValueMap.put(columnName, employee.getHomePhone());
} else if (columnName.equals("emergencyPhone")) {
entityValueMap.put(columnName, employee.getEmergencyPhone());
} else if (columnName.equals("educationlevel")) {
entityValueMap.put(columnName, employee.getEducationlevel());
} else if (columnName.equals("degree")) {
entityValueMap.put(columnName, employee.getDegree());
} else if (columnName.equals("graduatedUniversity")) {
entityValueMap.put(columnName, employee.getGraduatedUniversity());
} else if (columnName.equals("specialty")) {
entityValueMap.put(columnName, employee.getSpecialty());
} else if (columnName.equals("householdRegister")) {
entityValueMap.put(columnName, employee.getHouseholdRegister());
} else if (columnName.equals("technicalTitle")) {
entityValueMap.put(columnName, employee.getTechnicalTitle());
} else if (columnName.equals("dimissionType")) {
entityValueMap.put(columnName, employee.getDimissionType());
} else if (columnName.equals("recruitmentResource")) {
entityValueMap.put(columnName, employee.getRecruitmentResource());
} else if (columnName.equals("wageAccount")) {
entityValueMap.put(columnName, employee.getWageAccount());
} else if (columnName.equals("healthCareAccount")) {
entityValueMap.put(columnName, employee.getHealthCareAccount());
} else if (columnName.equals("accumulationFundAccount")) {
entityValueMap.put(columnName, employee.getAccumulationFundAccount());
} else if (columnName.equals("unemploymentInsurance")) {
entityValueMap.put(columnName, employee.getUnemploymentInsurance());
} else if (columnName.equals("socialInsurance")) {
entityValueMap.put(columnName, employee.getSocialInsurance());
} else if (columnName.equals("endowmentInsurance")) {
entityValueMap.put(columnName, employee.getEndowmentInsurance());
} else if (columnName.equals("homeAddress")) {
entityValueMap.put(columnName, employee.getHomeAddress());
} else if (columnName.equals("archivesAddress")) {
entityValueMap.put(columnName, employee.getArchivesAddress());
} else if (columnName.equals("workAddress")) {
entityValueMap.put(columnName, employee.getWorkAddress());
} else if (columnName.equals("employeeStatus")) {
entityValueMap.put(columnName, employee.getEmployeeStatus());
} else if (columnName.equals("workAddress")) {
entityValueMap.put(columnName, employee.getWorkAddress());
} else if (columnName.equals("dimissionReason")) {
entityValueMap.put(columnName, employee.getDimissionReason());
} else if (columnName.equals("workAddress")) {
entityValueMap.put(columnName, employee.getWorkAddress());
} else if (columnName.equals("birthDate")) {
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getBirthDate()));
} else if (columnName.equals("internshipStart")) {
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getInternshipStart()));
} else if (columnName.equals("internshipEnd")) {
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getGraduatedDate()));
} else if (columnName.equals("graduatedDate")) {
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getInternshipEnd()));
} else if (columnName.equals("contractStart")) {
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getContractStart()));
} else if (columnName.equals("contractEnd")) {
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getContractEnd()));
} else if (columnName.equals("onTrialDate")) {
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getOnTrialDate()));
} else if (columnName.equals("offTrialDate")) {
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getOffTrialDate()));
} else if (columnName.equals("entryDate")) {
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getEntryDate()));
} else if (columnName.equals("dimissionDate")) {
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getDimissionDate()));
} else if (columnName.equals("createDate")) {
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getCreateDate()));
} else if (columnName.equals("positionId")) {
long positionId = employee.getPositionId();
if (positionId > 0) {
Position position = PositionLocalServiceUtil.getPosition(positionId);
entityValueMap.put(columnName, position.getPosition());
} else {
entityValueMap.put(columnName, StringPool.BLANK);
}
} else if (columnName.equals("departmentId")) {
long departmentId = employee.getDepartmentId();
if (departmentId > 0) {
Department department = DepartmentLocalServiceUtil.getDepartment(departmentId);
entityValueMap.put(columnName, department.getDepartmentName());
} else {
entityValueMap.put(columnName, StringPool.BLANK);
}
} else if (columnName.equals("createUserId")) {
long createUserId = employee.getCreateUserId();
if (createUserId > 0) {
User user = UserLocalServiceUtil.getUser(createUserId);
entityValueMap.put(columnName, user.getScreenName());
} else {
entityValueMap.put(columnName, StringPool.BLANK);
}
} else if (columnName.equals("strField1")){
entityValueMap.put(columnName, employee.getStrField1());
} else if (columnName.equals("strField2")){
entityValueMap.put(columnName, employee.getStrField2());
} else if (columnName.equals("strField3")){
entityValueMap.put(columnName, employee.getStrField3());
} else if (columnName.equals("strField4")){
entityValueMap.put(columnName, employee.getStrField4());
} else if (columnName.equals("strField5")){
entityValueMap.put(columnName, employee.getStrField5());
} else if (columnName.equals("strField6")){
entityValueMap.put(columnName, employee.getStrField6());
} else if (columnName.equals("strField7")){
entityValueMap.put(columnName, employee.getStrField5());
} else if (columnName.equals("strField8")){
entityValueMap.put(columnName, employee.getStrField6());
} else if (columnName.equals("textareaField1")){
entityValueMap.put(columnName, employee.getTextareaField1());
} else if (columnName.equals("textareaField2")){
entityValueMap.put(columnName, employee.getTextareaField2());
} else if (columnName.equals("textareaField3")){
entityValueMap.put(columnName, employee.getTextareaField1());
} else if (columnName.equals("textareaField4")){
entityValueMap.put(columnName, employee.getTextareaField2());
} else if (columnName.equals("floatField1")){
entityValueMap.put(columnName, String.valueOf(employee.getFloatField1() == 0 ? "" : employee.getFloatField1()));
} else if (columnName.equals("floatField2")){
entityValueMap.put(columnName, String.valueOf(employee.getFloatField2() == 0 ? "" : employee.getFloatField2()));
} else if (columnName.equals("floatField3")){
entityValueMap.put(columnName, String.valueOf(employee.getFloatField3() == 0 ? "" : employee.getFloatField3()));
} else if (columnName.equals("floatField4")){
entityValueMap.put(columnName, String.valueOf(employee.getFloatField4() == 0 ? "" : employee.getFloatField4()));
} else if (columnName.equals("dateField1")){
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getDateField1()));
} else if (columnName.equals("dateField2")){
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getDateField2()));
} else if (columnName.equals("dateField3")){
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getDateField3()));
} else if (columnName.equals("dateField4")){
entityValueMap.put(columnName, DateUtil.formatDateNoHour(employee.getDateField4()));
}
}
}
}
return entityValueMap;
} // public static Map<String, String> getSocialRelationsValue(
// PortletRequest portletRequest, long socialRelationsId)
// throws PortalException, SystemException {
// Map<String, String> entityValueMap = null;
// long companyId = PortalUtil.getCompanyId(portletRequest);
// if (socialRelationsId > 0) {
// SocialRelations socialRelations = SocialRelationsLocalServiceUtil
// .getSocialRelations(socialRelationsId);
// if (socialRelations != null) {
// List<CompanyColumnDefinition> companyColumn = CompanyColumnDefinitionLocalServiceUtil
// .searchByTableName(companyId,TableConst.HRM_SocialRelation, true);
// entityValueMap = new HashMap<String, String>();
// for(CompanyColumnDefinition columnDefinition : companyColumn) {
// String columnName = columnDefinition.getColumnName();
// if(columnName.equals("company")){
// entityValueMap.put(columnName, String.valueOf(socialRelations.getCompany()));
// } else if (columnName.equals("position")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getPosition()));
// } else if (columnName.equals("workStatus")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getWorkStatus()));
// } else if (columnName.equals("mobilePhone")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getMobilePhone()));
// } else if (columnName.equals("companyId")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getCompanyId()));
// } else if (columnName.equals("memberRelations")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getMemberRalations()));
// } else if (columnName.equals("politicalStatus")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getPoliticalStatus()));
// } else if (columnName.equals("currentAddress")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getCurrentAddress()));
// } else if (columnName.equals("identityCard")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getIdentityCard()));
// } else if (columnName.equals("description")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getDescription()));
// } else if (columnName.equals("createDate")){
// entityValueMap.put(columnName, String.valueOf(socialRelations.getCreateDate()));
// } else if (columnName.equals("memberSex")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getMemberSex()));
// } else if (columnName.equals("employeeId")) {
// long employeeId = socialRelations.getEmployeeId();
// Employee employee = null;
// if (employeeId > 0) {
// employee = EmployeeLocalServiceUtil.getEmployee(employeeId);
// }
// entityValueMap.put(columnName, employee != null ? employee.getEmployeeName() : StringPool.BLANK);
// } else if (columnName.equals("postCode")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getPostCode()));
// } else if (columnName.equals("strField1")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getStrField1()));
// } else if (columnName.equals("strField2")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getStrField2()));
// } else if (columnName.equals("strField3")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getStrField3()));
// } else if (columnName.equals("strField4")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getStrField4()));
// } else if (columnName.equals("strField5")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getStrField5()));
// } else if (columnName.equals("strField6")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getStrField6()));
// } else if (columnName.equals("textareaField1")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getTextareaField1()));
// } else if (columnName.equals("textareaField2")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getTextareaField2()));
// } else if (columnName.equals("textareaField3")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getTextareaField3()));
// } else if (columnName.equals("textareaField4")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getTextareaField4()));
// } else if (columnName.equals("floatField1")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getFloatField1()));
// } else if (columnName.equals("floatField2")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getFloatField2()));
// } else if (columnName.equals("floatField3")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getFloatField3()));
// } else if (columnName.equals("floatField4")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getFloatField4()));
// } else if (columnName.equals("dateField1")) {
// entityValueMap.put(columnName, DateUtil.formatDateNoHour(socialRelations.getDateField1()));
// } else if (columnName.equals("dateField2")) {
// entityValueMap.put(columnName, DateUtil.formatDateNoHour(socialRelations.getDateField2()));
// } else if (columnName.equals("memberName")) {
// entityValueMap.put(columnName, String.valueOf(socialRelations.getMemberName()));
// }
// }
// }
// }
// return entityValueMap;
// } // public static Map<String, String> getWorkExperienceValue(PortletRequest portletRequest,
// Long workExperienceId) throws PortalException, SystemException{
// Map<String, String> entityValueMap = null;
// long companyId = PortalUtil.getCompanyId(portletRequest);
// if(workExperienceId > 0) {
// WorkExperience workExperience = WorkExperienceLocalServiceUtil.
// getWorkExperience(workExperienceId);
// if(workExperience != null) {
// List<CompanyColumnDefinition> columnDefinitions = CompanyColumnDefinitionLocalServiceUtil.
// searchByTableName(companyId, TableConst.HRM_WorkExperience, true);
// entityValueMap = new LinkedHashMap<String, String>();
// for (CompanyColumnDefinition columnDefinition : columnDefinitions) {
// String columnName = columnDefinition.getColumnName();
// if(columnName.equals("employeeId")){
// long employeeId = workExperience.getEmployeeId();
// Employee employee = null;
// if (employeeId > 0) {
// employee = EmployeeLocalServiceUtil.getEmployee(employeeId);
// }
// entityValueMap.put(columnName, employee != null ? employee.getEmployeeName() : StringPool.BLANK);
// } else if (columnName.equals("beginDate")) {
// entityValueMap.put(columnName, String.valueOf(DateUtil.formatDateNoHour(workExperience.getBeginDate())));
// } else if (columnName.equals("endDate")) {
// entityValueMap.put(columnName, String.valueOf(DateUtil.formatDateNoHour(workExperience.getEndDate())));
// } else if (columnName.equals("workCompany")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getWorkCompany()));
// } else if (columnName.equals("workDepartment")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getWorkDepartment()));
// } else if (columnName.equals("workPosition")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getWorkPosition()));
// } else if (columnName.equals("description")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getDescription()));
// } else if (columnName.equals("createDate")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getCreateDate()));
// } else if (columnName.equals("strField1")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getStrField1()));
// } else if (columnName.equals("strField2")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getStrField2()));
// } else if (columnName.equals("strField3")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getStrField3()));
// } else if (columnName.equals("strField4")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getStrField4()));
// } else if (columnName.equals("strField5")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getStrField5()));
// } else if (columnName.equals("strField6")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getStrField6()));
// } else if (columnName.equals("textareaField1")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getTextareaField1()));
// } else if (columnName.equals("textareaField2")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getTextareaField2()));
// } else if (columnName.equals("textareaField3")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getTextareaField3()));
// } else if (columnName.equals("textareaField4")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getTextareaField4()));
// } else if (columnName.equals("floatField1")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getFloatField1()));
// } else if (columnName.equals("floatField2")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getFloatField2()));
// } else if (columnName.equals("floatField3")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getFloatField3()));
// } else if (columnName.equals("floatField4")) {
// entityValueMap.put(columnName, String.valueOf(workExperience.getFloatField4()));
// } else if (columnName.equals("dateField1")) {
// entityValueMap.put(columnName, DateUtil.formatDateNoHour(workExperience.getDateField1()));
// } else if (columnName.equals("dateField2")) {
// entityValueMap.put(columnName, DateUtil.formatDateNoHour(workExperience.getDateField2()));
// }
// }
// }
// }
// return entityValueMap;
// } // public static Map<String, String> getTrainingExperienceValue(
// PortletRequest portletRequest, long trainingExperienceId) throws PortalException, SystemException {
// Map<String, String> entityValueMap = null;
// long companyId = PortalUtil.getCompanyId(portletRequest);
// if(trainingExperienceId > 0) {
// TrainingExperience trainingExperience = TrainingExperienceLocalServiceUtil.
// getTrainingExperience(trainingExperienceId);
// if (trainingExperience != null) {
// List<CompanyColumnDefinition> columnDefinitions =
// CompanyColumnDefinitionLocalServiceUtil.searchByTableName(
// companyId, TableConst.HRM_TrainingExperience, true);
// entityValueMap = new HashMap<String, String>();
// for (CompanyColumnDefinition columnDefinition : columnDefinitions) {
// String columnName = columnDefinition.getColumnName();
// if (columnName.equals("employeeId")) {
// long employeeId = trainingExperience.getEmployeeId();
// Employee employee = null;
// if (employeeId > 0) {
// employee = EmployeeLocalServiceUtil.getEmployee(employeeId);
// }
// entityValueMap.put(columnName, employee != null ? employee.getEmployeeName() : StringPool.BLANK);
// } else if (columnName.equals("beginDate")) {
// entityValueMap.put(columnName, String.valueOf(
// DateUtil.formatDateNoHour(trainingExperience.getBeginDate())));
// } else if (columnName.equals("endDate")) {
// entityValueMap.put(columnName, String.valueOf(
// DateUtil.formatDateNoHour(trainingExperience.getEndDate())));
// } else if (columnName.equals("trainingDays")) {
// entityValueMap.put(columnName, String.valueOf(
// trainingExperience.getTrainingDays()));
// } else if (columnName.equals("trainingType")) {
// entityValueMap.put(columnName, String.valueOf(
// trainingExperience.getTrainingType()));
// } else if (columnName.equals("trainingContent")) {
// entityValueMap.put(columnName, String.valueOf(
// trainingExperience.getTrainingContent()));
// } else if (columnName.equals("trainingCost")) {
// entityValueMap.put(columnName, String.valueOf(
// trainingExperience.getTrainingCost()));
// } else if (columnName.equals("trainingCompany")) {
// entityValueMap.put(columnName, String.valueOf(
// trainingExperience.getTrainingCompany()));
// } else if (columnName.equals("organizeCompany")) {
// entityValueMap.put(columnName, String.valueOf(
// trainingExperience.getOrganizeCompany()));
// } else if (columnName.equals("description")) {
// entityValueMap.put(columnName, String.valueOf(
// trainingExperience.getDescription()));
// } else if (columnName.equals("createDate")) {
// entityValueMap.put(columnName, String.valueOf(
// trainingExperience.getCreateDate()));
// } else if (columnName.equals("strField1")) {
// entityValueMap.put(columnName, String.valueOf(trainingExperience.getStrField1()));
// } else if (columnName.equals("strField2")) {
// entityValueMap.put(columnName, String.valueOf(trainingExperience.getStrField2()));
// } else if (columnName.equals("strField3")) {
// entityValueMap.put(columnName, String.valueOf(trainingExperience.getStrField3()));
// } else if (columnName.equals("strField4")) {
// entityValueMap.put(columnName, String.valueOf(trainingExperience.getStrField4()));
// } else if (columnName.equals("strField5")) {
// entityValueMap.put(columnName, String.valueOf(trainingExperience.getStrField5()));
// } else if (columnName.equals("strField6")) {
// entityValueMap.put(columnName, String.valueOf(trainingExperience.getStrField6()));
// } else if (columnName.equals("textareaField1")) {
// entityValueMap.put(columnName, String.valueOf(trainingExperience.getTextareaField1()));
// } else if (columnName.equals("textareaField2")) {
// entityValueMap.put(columnName, String.valueOf(trainingExperience.getTextareaField2()));
// } else if (columnName.equals("textareaField3")) {
// entityValueMap.put(columnName, String.valueOf(trainingExperience.getTextareaField3()));
// } else if (columnName.equals("textareaField4")) {
// entityValueMap.put(columnName, String.valueOf(trainingExperience.getTextareaField4()));
// } else if (columnName.equals("floatField1")) {
// entityValueMap.put(columnName, String.valueOf(trainingExperience.getFloatField1()));
// } else if (columnName.equals("floatField2")) {
// entityValueMap.put(columnName, String.valueOf(trainingExperience.getFloatField2()));
// } else if (columnName.equals("floatField3")) {
// entityValueMap.put(columnName, String.valueOf(trainingExperience.getFloatField3()));
// } else if (columnName.equals("floatField4")) {
// entityValueMap.put(columnName, String.valueOf(trainingExperience.getFloatField4()));
// } else if (columnName.equals("dateField1")) {
// entityValueMap.put(columnName, DateUtil.formatDateNoHour(trainingExperience.getDateField1()));
// } else if (columnName.equals("dateField2")) {
// entityValueMap.put(columnName, DateUtil.formatDateNoHour(trainingExperience.getDateField2()));
// }
// }
// }
// }
// return entityValueMap;
// } // public static Map<String, String> getStudyExperienceValue(PortletRequest portletRequest, Long studyExperienceId)
// throws PortalException, SystemException {
//
// Map<String, String> entityValueMap = null;
// long companyId = PortalUtil.getCompanyId(portletRequest);
// if (studyExperienceId > 0){
// StudyExperience studyExperience = StudyExperienceLocalServiceUtil.getStudyExperience(studyExperienceId);
// if (studyExperience != null){
// List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil
// .searchByTableName(companyId, TableConst.HRM_StudyExperience, true);
// entityValueMap = new HashMap<String, String>();
// for (CompanyColumnDefinition companyColumn : companyColumns) {
// String columnName = companyColumn.getColumnName();
// if (columnName.equals("employeeId")) {
// long employeeId=studyExperience.getEmployeeId();
// if(employeeId>0){
// Employee employee=EmployeeLocalServiceUtil.getEmployee(employeeId);
// entityValueMap.put(columnName, employee.getEmployeeName());
// }else{
// entityValueMap.put(columnName, StringPool.BLANK);
// }
// } else if (columnName.equals("startDate")) {
// entityValueMap.put(columnName,DateUtil.formatDateNoHour(studyExperience.getStartDate()));
// } else if (columnName.equals("endDate")) {
// entityValueMap.put(columnName,DateUtil.formatDateNoHour(studyExperience.getEndDate()));
// } else if (columnName.equals("studySchool")) {
// entityValueMap.put(columnName,studyExperience.getStudySchool());
// } else if (columnName.equals("degree")) {
// entityValueMap.put(columnName,studyExperience.getDegree());
// } else if (columnName.equals("degreeNo")) {
// entityValueMap.put(columnName,studyExperience.getDegreeNo());
// } else if (columnName.equals("educationLevel")) {
// entityValueMap.put(columnName,studyExperience.getEducationLevel());
// } else if (columnName.equals("educationNo")) {
// entityValueMap.put(columnName,studyExperience.getEducationNo());
// } else if (columnName.equals("specialtyCourses")) {
// entityValueMap.put(columnName,studyExperience.getSpecialtyCourses());
// } else if (columnName.equals("isHighestDegree")) {
// Locale locale = PortalUtil.getHttpServletRequest(portletRequest).getLocale();
// String str=LanguageUtil.get(PortletIDs.INITIALIZATION, locale, "No");
// if(studyExperience.getIsHighestDegree()){
// str = LanguageUtil.get(PortletIDs.INITIALIZATION, locale, "Yes");
// }
// entityValueMap.put(columnName, str);
// } else if (columnName.equals("isHighestEducation")) {
// Locale locale = PortalUtil.getHttpServletRequest(portletRequest).getLocale();
// String str = LanguageUtil.get(PortletIDs.INITIALIZATION, locale, "No");
// if(studyExperience.getIsHighestEducation()){
// str = LanguageUtil.get(PortletIDs.INITIALIZATION, locale, "Yes");
// }
// entityValueMap.put(columnName, str);
// } else if (columnName.equals("foreignLanguage")) {
// entityValueMap.put(columnName, studyExperience.getForeignLanguage());
// }else if (columnName.equals("foreignLanguageLevel")) {
// entityValueMap.put(columnName,studyExperience.getForeignLanguageLevel());
// }else if (columnName.equals("createDate")) {
// entityValueMap.put(columnName,DateUtil.formatDateNoHour(studyExperience.getCreateDate()));
// }else if (columnName.equals("strField1")){
// entityValueMap.put(columnName, studyExperience.getStrField1());
// } else if (columnName.equals("strField2")){
// entityValueMap.put(columnName, studyExperience.getStrField2());
// } else if (columnName.equals("strField3")){
// entityValueMap.put(columnName, studyExperience.getStrField3());
// } else if (columnName.equals("strField4")){
// entityValueMap.put(columnName, studyExperience.getStrField4());
// } else if (columnName.equals("strField5")){
// entityValueMap.put(columnName, studyExperience.getStrField5());
// } else if (columnName.equals("strField6")){
// entityValueMap.put(columnName, studyExperience.getStrField6());
// } else if (columnName.equals("textareaField1")){
// entityValueMap.put(columnName, studyExperience.getTextareaField1());
// } else if (columnName.equals("textareaField2")){
// entityValueMap.put(columnName, studyExperience.getTextareaField2());
// } else if (columnName.equals("textareaField3")){
// entityValueMap.put(columnName, studyExperience.getTextareaField1());
// } else if (columnName.equals("textareaField4")){
// entityValueMap.put(columnName, studyExperience.getTextareaField2());
// } else if (columnName.equals("floatField1")){
// entityValueMap.put(columnName, String.valueOf(studyExperience.getFloatField1() == 0 ? "" : studyExperience.getFloatField1()));
// } else if (columnName.equals("floatField2")){
// entityValueMap.put(columnName, String.valueOf(studyExperience.getFloatField2() == 0 ? "" : studyExperience.getFloatField2()));
// } else if (columnName.equals("floatField3")){
// entityValueMap.put(columnName, String.valueOf(studyExperience.getFloatField3() == 0 ? "" : studyExperience.getFloatField3()));
// } else if (columnName.equals("floatField4")){
// entityValueMap.put(columnName, String.valueOf(studyExperience.getFloatField4() == 0 ? "" : studyExperience.getFloatField4()));
// } else if (columnName.equals("dateField1")){
// entityValueMap.put(columnName, DateUtil.formatDateNoHour(studyExperience.getDateField1()));
// } else if (columnName.equals("dateField2")){
// entityValueMap.put(columnName, DateUtil.formatDateNoHour(studyExperience.getDateField2()));
// }
// }
// }
// }
// return entityValueMap;
// } // public static Map<String, String> getEmployeeSkillsValue(PortletRequest portletRequest, Long employeeSkillsId)
// throws PortalException, SystemException {
//
// Map<String, String> entityValueMap = null;
// long companyId = PortalUtil.getCompanyId(portletRequest);
// if (employeeSkillsId > 0){
// EmployeeSkills employeeSkills=EmployeeSkillsLocalServiceUtil.getEmployeeSkills(employeeSkillsId);
// if (employeeSkills != null){
// List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil.searchByTableName(companyId, TableConst.CRM_EmployeeSkills, true);
// entityValueMap = new HashMap<String, String>();
// for (CompanyColumnDefinition companyColumn : companyColumns) {
// String columnName = companyColumn.getColumnName();
// if (columnName.equals("employeeId")) {
// long employeeId=employeeSkills.getEmployeeId();
// if(employeeId>0){
// Employee employee=EmployeeLocalServiceUtil.getEmployee(employeeId);
// entityValueMap.put(columnName, employee.getEmployeeName());
// }else{
// entityValueMap.put(columnName, StringPool.BLANK);
// }
// } else if (columnName.equals("skillId")) {
// long skillId=employeeSkills.getSkillId();
// if(skillId>0){
// Skill skill=SkillLocalServiceUtil.getSkill(skillId);
// entityValueMap.put(columnName,skill.getSkillName());
// }else{
// entityValueMap.put(columnName,StringPool.BLANK);
// }
// } else if (columnName.equals("obtainDate")) {
// entityValueMap.put(columnName,DateUtil.formatDateNoHour(employeeSkills.getObtainDate()));
// } else if (columnName.equals("obtainType")) {
// entityValueMap.put(columnName,employeeSkills.getObtainType());
// } else if (columnName.equals("certificateNo")) {
// entityValueMap.put(columnName,employeeSkills.getCertificateNo());
// } else if (columnName.equals("description")) {
// entityValueMap.put(columnName,employeeSkills.getDescription());
// } else if (columnName.equals("strField1")){
// entityValueMap.put(columnName, employeeSkills.getStrField1());
// } else if (columnName.equals("strField2")){
// entityValueMap.put(columnName, employeeSkills.getStrField2());
// } else if (columnName.equals("strField3")){
// entityValueMap.put(columnName, employeeSkills.getStrField3());
// } else if (columnName.equals("strField4")){
// entityValueMap.put(columnName, employeeSkills.getStrField4());
// } else if (columnName.equals("strField5")){
// entityValueMap.put(columnName, employeeSkills.getStrField5());
// } else if (columnName.equals("strField6")){
// entityValueMap.put(columnName, employeeSkills.getStrField6());
// } else if (columnName.equals("textareaField1")){
// entityValueMap.put(columnName, employeeSkills.getTextareaField1());
// } else if (columnName.equals("textareaField2")){
// entityValueMap.put(columnName, employeeSkills.getTextareaField2());
// } else if (columnName.equals("textareaField3")){
// entityValueMap.put(columnName, employeeSkills.getTextareaField1());
// } else if (columnName.equals("textareaField4")){
// entityValueMap.put(columnName, employeeSkills.getTextareaField2());
// } else if (columnName.equals("floatField1")){
// entityValueMap.put(columnName, String.valueOf(employeeSkills.getFloatField1() == 0 ? "" : employeeSkills.getFloatField1()));
// } else if (columnName.equals("floatField2")){
// entityValueMap.put(columnName, String.valueOf(employeeSkills.getFloatField2() == 0 ? "" : employeeSkills.getFloatField2()));
// } else if (columnName.equals("floatField3")){
// entityValueMap.put(columnName, String.valueOf(employeeSkills.getFloatField3() == 0 ? "" : employeeSkills.getFloatField3()));
// } else if (columnName.equals("floatField4")){
// entityValueMap.put(columnName, String.valueOf(employeeSkills.getFloatField4() == 0 ? "" : employeeSkills.getFloatField4()));
// } else if (columnName.equals("dateField1")){
// entityValueMap.put(columnName, DateUtil.formatDateNoHour(employeeSkills.getDateField1()));
// } else if (columnName.equals("dateField2")){
// entityValueMap.put(columnName, DateUtil.formatDateNoHour(employeeSkills.getDateField2()));
// }
// }
// }
// }
// return entityValueMap;
// }
// public static Map<String, String> getSkillValue(PortletRequest portletRequest, Long skillId)
// throws PortalException, SystemException {
//
// Map<String, String> entityValueMap = null;
// long companyId = PortalUtil.getCompanyId(portletRequest);
// if (skillId > 0){
// Skill skill=SkillLocalServiceUtil.getSkill(skillId);
// if (skill != null){
// List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil.searchByTableName(companyId, TableConst.HRM_Skill, true);
// entityValueMap = new HashMap<String, String>();
// for (CompanyColumnDefinition companyColumn : companyColumns) {
// String columnName = companyColumn.getColumnName();
// if (columnName.equals("skillNo")) {
// entityValueMap.put(columnName, skill.getSkillNo());
// } else if (columnName.equals("skillName")) {
// entityValueMap.put(columnName,skill.getSkillName());
// } else if (columnName.equals("skillIndex")) {
// entityValueMap.put(columnName,String.valueOf(skill.getSkillIndex()));
// } else if (columnName.equals("skillCategoryId")) {
// entityValueMap.put(columnName,String.valueOf(skill.getSkillCategoryId()));
// } else if (columnName.equals("description")) {
// entityValueMap.put(columnName,skill.getDescription());
// } else if (columnName.equals("strField1")){
// entityValueMap.put(columnName, skill.getStrField1());
// } else if (columnName.equals("strField2")){
// entityValueMap.put(columnName, skill.getStrField2());
// } else if (columnName.equals("strField3")){
// entityValueMap.put(columnName, skill.getStrField3());
// } else if (columnName.equals("strField4")){
// entityValueMap.put(columnName, skill.getStrField4());
// } else if (columnName.equals("strField5")){
// entityValueMap.put(columnName, skill.getStrField5());
// } else if (columnName.equals("strField6")){
// entityValueMap.put(columnName, skill.getStrField6());
// } else if (columnName.equals("textareaField1")){
// entityValueMap.put(columnName, skill.getTextareaField1());
// } else if (columnName.equals("textareaField2")){
// entityValueMap.put(columnName, skill.getTextareaField2());
// } else if (columnName.equals("textareaField3")){
// entityValueMap.put(columnName, skill.getTextareaField1());
// } else if (columnName.equals("textareaField4")){
// entityValueMap.put(columnName, skill.getTextareaField2());
// } else if (columnName.equals("floatField1")){
// entityValueMap.put(columnName, String.valueOf(skill.getFloatField1() == 0 ? "" : skill.getFloatField1()));
// } else if (columnName.equals("floatField2")){
// entityValueMap.put(columnName, String.valueOf(skill.getFloatField2() == 0 ? "" : skill.getFloatField2()));
// } else if (columnName.equals("floatField3")){
// entityValueMap.put(columnName, String.valueOf(skill.getFloatField3() == 0 ? "" : skill.getFloatField3()));
// } else if (columnName.equals("floatField4")){
// entityValueMap.put(columnName, String.valueOf(skill.getFloatField4() == 0 ? "" : skill.getFloatField4()));
// } else if (columnName.equals("dateField1")){
// entityValueMap.put(columnName, DateUtil.formatDateNoHour(skill.getDateField1()));
// } else if (columnName.equals("dateField2")){
// entityValueMap.put(columnName, DateUtil.formatDateNoHour(skill.getDateField2()));
// }
// }
// }
// }
// return entityValueMap;
// } // public static Map<String, String> getDepartmentValue(
// PortletRequest portletRequest, long departmentId) throws PortalException, SystemException{
// Map<String, String> map = null;
// Long companyId = PortalUtil.getCompanyId(portletRequest);
// if (departmentId > 0) {
// Department department = DepartmentLocalServiceUtil.getDepartment(departmentId);
// if (department != null) {
// List<CompanyColumnDefinition> list = CompanyColumnDefinitionLocalServiceUtil
// .searchByTableName(companyId, TableConst.HRM_Department, true);
// map = new HashMap<String, String>();
// for(CompanyColumnDefinition columnDefinition : list){
// String columnName = columnDefinition.getColumnName();
// if (columnName.equals("departmentNo")) {
// map.put(columnName, String.valueOf(department.getDepartmentNo()));
// } else if (columnName.equals("departmentName")) {
// map.put(columnName, String.valueOf(department.getDepartmentName()));
// } else if (columnName.equals("departmentIndex")) {
// map.put(columnName, String.valueOf(department.getDepartmentIndex()));
// } else if (columnName.equals("departmentTel")) {
// map.put(columnName, String.valueOf(department.getDepartmentTel()));
// } else if (columnName.equals("departmentAddress")) {
// map.put(columnName, String.valueOf(department.getDepartmentAddress()));
// } else if (columnName.equals("departmentCategory")) {
// map.put(columnName, String.valueOf(department.getDepartmentCategory()));
// } else if (columnName.equals("parentDepartmentId")) {
// long parentDepartmentId = department.getParentDepartmentId();
// Department parentDepartment = null;
// if (parentDepartmentId > 0) {
// parentDepartment = DepartmentLocalServiceUtil.getDepartment(parentDepartmentId);
// }
// map.put(columnName, parentDepartment != null ? parentDepartment.getDepartmentName() : StringPool.BLANK);
// }
// }
// }
// }
// return map;
// } public static void getPrefenceColumn(PortletRequest portletRequest)
throws NumberFormatException, PortalException, SystemException { PortletPreferences preferences = portletRequest.getPreferences();
String columnsIds = preferences.getValue("default.display.columns", "");
List<CompanyColumnDefinition> tableHeader = null;
if (!columnsIds.equals(StringPool.BLANK)) {
String[] columnIdsArray = columnsIds.split(StringPool.COMMA);
tableHeader = new ArrayList<CompanyColumnDefinition>();
for (int i = 0; i < columnIdsArray.length; i++) {
CompanyColumnDefinition companyColumn = CompanyColumnDefinitionLocalServiceUtil
.getCompanyColumnDefinition(Long.valueOf(columnIdsArray[i]));
tableHeader.add(companyColumn); }
}
portletRequest.setAttribute("tableHeader", tableHeader);
} }

3:需要用一个Validate.form.js这个文件。放在js文件夹下,因为我们需要前台写录入信息的时候需要验证。

4:需要写一个初始化默认字段的一个类(需要写的是this.initializingXXXColumn(companyId))这个是写在CRM项目中去的,到时候我可以在Operator-portlet这个项目中直接用的。

package com.ebizwindow.crm.init;

import java.util.List;
import java.util.Locale; import com.ebizwindow.crm.NoSuchTableDefinitionException;
import com.ebizwindow.crm.constants.ColumnConst;
import com.ebizwindow.crm.constants.FormConst;
import com.ebizwindow.crm.constants.PortletIDs;
import com.ebizwindow.crm.constants.PortletPropsValues;
import com.ebizwindow.crm.constants.TableConst;
import com.ebizwindow.crm.model.ColumnColumnGroupDefinition;
import com.ebizwindow.crm.model.ColumnDefinition;
import com.ebizwindow.crm.model.ColumnGroupDefinition;
import com.ebizwindow.crm.model.TableDefinition;
import com.ebizwindow.crm.service.ColumnColumnGroupDefinitionLocalServiceUtil;
import com.ebizwindow.crm.service.ColumnDefinitionLocalServiceUtil;
import com.ebizwindow.crm.service.ColumnGroupDefinitionLocalServiceUtil;
import com.ebizwindow.crm.service.TableDefinitionLocalServiceUtil;
import com.ebizwindow.crm.utils.IDGenerator;
import com.ebizwindow.crm.utils.LanguageUtil;
import com.ebizwindow.crm.utils.Validator;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.model.Company;
import com.liferay.portal.service.CompanyLocalServiceUtil; public class InitializingDefaultColumn { private static final int PC_COLUMN_GROUP_TYPE_DETAIL = 0;
private static final int PC_COLUMN_GROUP_TYPE_EDIT = 1; private static final int ANDROID_COLUMN_GROUP_TYPE_DETAIL = 2;
private static final int ANDROID_COLUMN_GROUP_TYPE_EDIT = 3; public static final boolean DISPALY_0 = false;
public static final boolean DISPALY_1 = true; public void initializing(long companyId)
throws SystemException, PortalException { this.initializingTableDefinition();
this.initializingClueColumn(companyId);
this.initializingMarketColumn(companyId);
this.initializingCustomerColumn(companyId);
this.initializingContactColumn(companyId);
this.initializingOpportuntiyColumn(companyId);
this.initializingQuotationColumn(companyId);
this.initializingOrderColumn(companyId);
this.initializingActivityColumn(companyId);
this.initializingProductColumn(companyId);
this.initializingContractColumn(companyId);
this.initializingOperatorColumn(companyId);
this.initializingRPlan(companyId);
this.initializingRRecord(companyId);
this.initializingProjectColumn(companyId); this.initializingCreditRightsColumn(companyId); this.initializingEmployeeColumn(companyId); _log.debug("Initializing Default Column Successfully ...");
} private void initializingEmployeeColumn(long companyId) throws SystemException, PortalException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(TableConst.CRM_Employee); Company company = CompanyLocalServiceUtil.getCompany(companyId);
Locale locale = company.getLocale(); String[] selectType = ColumnConst.employee_select_columns;
String[] integerType = ColumnConst.employee_integer_columns;
String[] textType = ColumnConst.employee_text_columns;
String[] pkType = ColumnConst.employee_pk_columns;
String[] textareaType = ColumnConst.employee_textarea_columns;
String[] dateType = ColumnConst.employee_date_columns; for (int i = 0; i < selectType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(selectType[i].substring(selectType[i].length() - 2));
String columnName = selectType[i].substring(0, selectType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("employee." + columnName);
columnDefinition.setDefaultFormType(FormConst.select);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
} for (int i = 0; i < integerType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(integerType[i].substring(integerType[i].length() - 2));
String columnName = integerType[i].substring(0, integerType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("employee." + columnName);
columnDefinition.setDefaultFormType(FormConst.integer_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
} for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i].substring(textType[i].length() - 2));
String columnName = textType[i].substring(0,textType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("employee." + columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1); if (columnName.equals("employeeName")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition.setVerifyTips(LanguageUtil.get(PortletIDs.INITIALIZATION,
locale, FormConst.VERIFY_NOT_NULL_TIPS));
} if (columnName.equals("departmentName") || columnName.equals("positionName")) {
columnDefinition.setIsDisplayInPage(DISPALY_0);
} else {
columnDefinition.setIsDisplayInPage(DISPALY_0);
} ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); }
} for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i].substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0,pkType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("employee." + columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition);
}
} for (int i = 0; i < textareaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textareaType[i].substring(textareaType[i].length() - 2));
String columnName = textareaType[i].substring(0, textareaType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition
.setDefaultDisplayName("employee." + columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
} for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i].substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0,dateType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition
.setDefaultDisplayName("employee." + columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
columnDefinition.setTableDefinitionId(tableDefinitionId);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
} for (int i = 1; i < 7; i++) {
String columnName = "strField" + i;
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_0);
columnDefinition.setDisplayInEditPage(DISPALY_0);
columnDefinition.setIsDisplayInPage(DISPALY_0);
columnDefinition.setIsCustom(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
} for (int i = 1; i < 3; i++) {
String columnName = "textareaField" + i;
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName("textareaField" + i);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_0);
columnDefinition.setDisplayInEditPage(DISPALY_0);
columnDefinition.setIsDisplayInPage(DISPALY_0);
columnDefinition.setIsCustom(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
} for (int i = 1; i < 4; i++) {
String columnName = "floatField" + i;
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName("floatField" + i);
columnDefinition.setDefaultFormType(FormConst.float_);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_0);
columnDefinition.setDisplayInEditPage(DISPALY_0);
columnDefinition.setIsDisplayInPage(DISPALY_0);
columnDefinition.setIsCustom(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
} for (int i = 1; i < 4; i++) {
String columnName = "dateField" + i;
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName("dateField" + i);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_0);
columnDefinition.setDisplayInEditPage(DISPALY_0);
columnDefinition.setIsDisplayInPage(DISPALY_0);
columnDefinition.setIsCustom(DISPALY_1);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition);
}
} String[] notDisplayInEditPage = ColumnConst.employee_editpage_invisible_columns;
for (int i = 0; i < notDisplayInEditPage.length; i++) {
String columnName = notDisplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
columnDefinition.setDisplayInEditPage(DISPALY_0);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
} String[] notDisplayInDetailPage = ColumnConst.employee_detailpage_invisible_columns;
for (int i = 0; i < notDisplayInDetailPage.length; i++) {
String columnName = notDisplayInDetailPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
columnDefinition.setDisplayInDetailPage(DISPALY_0);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
} ColumnGroupDefinition baseGroupColumn_Edit = createBaseGroup_Edit(TableConst.CRM_Employee, locale);
ColumnGroupDefinition baseGroupColumn_Detail = createBaseGroup_Detail(TableConst.CRM_Employee, locale);
ColumnGroupDefinition contactGroupColumn_Edit = createContactGroup_Edit(TableConst.CRM_Employee, locale);
ColumnGroupDefinition contactGroupColumn_Detail = createContactGroup_Detail(TableConst.CRM_Employee, locale);
ColumnGroupDefinition accountGroupColumn_Edit = createAccountGroup_Edit(TableConst.CRM_Employee, locale);
ColumnGroupDefinition accountGroupColumn_Detail = createAccountGroup_Detail(TableConst.CRM_Employee, locale); String[] baseGroupColumns = ColumnConst.employee_base_group_columns;
for (int i = 0; i < baseGroupColumns.length; i++) {
String columnName = baseGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(baseGroupColumn_Detail.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(baseGroupColumn_Edit.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInEditPage);
} String[] contactGroupColumns = ColumnConst.employee_contact_group_columns;
for (int i = 0; i < contactGroupColumns.length; i++) {
String columnName = contactGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(contactGroupColumn_Detail.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(contactGroupColumn_Edit.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInEditPage);
} String[] accountGroupColumns = ColumnConst.employee_account_group_columns;
for (int i = 0; i < accountGroupColumns.length; i++) {
String columnName = accountGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Employee, columnName);
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(accountGroupColumn_Detail.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(accountGroupColumn_Edit.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInEditPage);
}
} private ColumnGroupDefinition createBaseGroup_Edit(
String tableName, Locale locale) throws SystemException, NoSuchTableDefinitionException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(tableName);
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION,
locale, PortletPropsValues.COLUMN_GROUP_BASE); ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(tableDefinitionId, groupDisplayName, 1);
ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null){
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(0);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(1);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil.updateColumnGroupDefinition(columnGroupInEditPage);
}
return columnGroupInEditPage;
} private ColumnGroupDefinition createBaseGroup_Detail(
String tableName, Locale locale) throws PortalException, SystemException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(tableName);
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION,
locale, PortletPropsValues.COLUMN_GROUP_BASE);
ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(tableDefinitionId, groupDisplayName, 0);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null){
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(0);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(0);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil.updateColumnGroupDefinition(columnGroupInDetailPage);
}
return columnGroupInDetailPage;
} private ColumnGroupDefinition createContactGroup_Edit(
String tableName, Locale locale) throws SystemException, NoSuchTableDefinitionException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(tableName);
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION,
locale, "column.group.contact"); ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(tableDefinitionId, groupDisplayName, 1);
ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null){
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(1);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(1);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil.updateColumnGroupDefinition(columnGroupInEditPage);
}
return columnGroupInEditPage;
} private ColumnGroupDefinition createContactGroup_Detail(
String tableName, Locale locale) throws PortalException, SystemException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(tableName);
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION, locale, "column.group.contact");
ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(tableDefinitionId, groupDisplayName, 0);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null){
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(1);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(0);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil.updateColumnGroupDefinition(columnGroupInDetailPage);
}
return columnGroupInDetailPage;
} private ColumnGroupDefinition createAccountGroup_Edit(
String tableName, Locale locale) throws SystemException, NoSuchTableDefinitionException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(tableName);
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION,
locale, "column.group.account"); ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(tableDefinitionId, groupDisplayName, 1);
ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null){
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(2);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(1);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil.updateColumnGroupDefinition(columnGroupInEditPage);
}
return columnGroupInEditPage;
} private ColumnGroupDefinition createAccountGroup_Detail(
String tableName, Locale locale) throws PortalException, SystemException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(tableName);
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION,
locale, "column.group.account");
ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(tableDefinitionId, groupDisplayName, 0);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null){
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(2);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(0);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil.updateColumnGroupDefinition(columnGroupInDetailPage);
}
return columnGroupInDetailPage;
} private void initializingTableDefinition() throws SystemException,
NoSuchTableDefinitionException { String[] tableName = new String[] { TableConst.CRM_Market,
TableConst.CRM_Customer, TableConst.CRM_Contact,
TableConst.CRM_Clue, TableConst.CRM_Opportunity,
TableConst.CRM_Quotation, TableConst.CRM_Activity,
TableConst.CRM_Product, TableConst.CRM_Contract,
TableConst.OPERATOR_Department, TableConst.OPERATOR_Operator,
TableConst.CRM_Order, TableConst.CRM_RPLAN, TableConst.CRM_RRECORD,
TableConst.CRM_Project,TableConst.CR_CreditRights,TableConst.CRM_Employee
}; for (int i = 0; i < tableName.length; i++) {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(tableName[i]);
if (tableDefinitionId <= 0) {
TableDefinition tableDefinition = TableDefinitionLocalServiceUtil
.createTableDefinition(IDGenerator.increment(TableDefinition.class.getName()));
tableDefinition.setTableName(tableName[i]);
TableDefinitionLocalServiceUtil.addTableDefinition(tableDefinition);
}
}
} private void initializingCreditRightsColumn(long companyId) throws PortalException,SystemException{
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Locale locale = company.getLocale(); long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(TableConst.CR_CreditRights);
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION, locale, PortletPropsValues.COLUMN_GROUP_BASE); ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 0);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null){
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(0);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(PC_COLUMN_GROUP_TYPE_DETAIL);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil.updateColumnGroupDefinition(columnGroupInDetailPage);
} ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 1);
ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null){
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(0);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(PC_COLUMN_GROUP_TYPE_EDIT);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil.updateColumnGroupDefinition(columnGroupInEditPage);
} String[] dateType = ColumnConst.CREDITRIGHTS_DATE_TYPE;
String[] selectType = ColumnConst.CREDITRIGHTS_SELECT_TYPE;
String[] textType = ColumnConst.CREDITRIGHTS_TEXT_TYPE;
String[] pkType = ColumnConst.CREDITRIGHTS_PK_TYPE;
String[] doubleType = ColumnConst.CREDITRIGHTS_DOUBLE_TYPE;
String[] textAreaType = ColumnConst.CREDITRIGHTS_TEXTAREA_TYPE;
String[] integerType = ColumnConst.CREDITRIGHTS_INTEGER_TYPE;
String[] booleanType = ColumnConst.CREDITRIGHTS_INTEGER_TYPE; for (int i = 0; i < booleanType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(booleanType[i].substring(booleanType[i].length() - 2));
String columnName = booleanType[i].substring(0, booleanType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CR_CreditRights, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("creditRights."+columnName);
columnDefinition.setDefaultFormType(FormConst.boolean_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
columnDefinition.setTableDefinitionId(tableDefinitionId); if (columnName.equals("isActive")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
} ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(), columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId()); } else {
_log.info(TableConst.CR_CreditRights + " - " + columnName + " is exists...");
}
} for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i].substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0, dateType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CR_CreditRights, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("creditRights."+columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
columnDefinition.setTableDefinitionId(tableDefinitionId);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CR_CreditRights + " - " + columnName + " is exists...");
}
} for (int i = 0; i < selectType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(selectType[i].substring(selectType[i].length() - 2));
String columnName = selectType[i].substring(0, selectType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CR_CreditRights, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("creditRights."+columnName);
columnDefinition.setDefaultFormType(FormConst.select);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("creditRightsAge")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
} ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(), columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId()); } else {
_log.info(TableConst.CR_CreditRights + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i].substring(textType[i].length() - 2));
String columnName = textType[i].substring(0, textType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CR_CreditRights, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("creditRights."+columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(), columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CR_CreditRights + " - " + columnName + " is exists...");
}
} for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i].substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0, pkType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CR_CreditRights, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("creditRights."+columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CR_CreditRights + " - " + columnName + " is exists...");
}
} for (int i = 0; i < doubleType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(doubleType[i].substring(doubleType[i].length() - 2));
String columnName = doubleType[i].substring(0, doubleType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CR_CreditRights, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("creditRights." + columnName);
columnDefinition.setDefaultFormType(FormConst.double_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CR_CreditRights + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textAreaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textAreaType[i].substring(textAreaType[i].length() - 2));
String columnName = textAreaType[i].substring(0, textAreaType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CR_CreditRights, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition
.setDefaultDisplayName("creditRights." + columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CR_CreditRights + " - " + columnName + " is exists...");
}
} for (int i = 0; i < integerType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(integerType[i].substring(integerType[i].length() - 2));
String columnName = integerType[i].substring(0, integerType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CR_CreditRights, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("creditRights."+columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(), columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CR_CreditRights + " - " + columnName + " is exists...");
}
} this.initConfigField(tableDefinitionId,TableConst.CR_CreditRights); String[] notDisplayInEditPage = ColumnConst.CREDITRIGHTS_NOT_DISPLAY_IN_EDIT_PAGE;
String[] notUseInDetailPage = ColumnConst.CREDITRIGHTS_NOT_USE_IN_DEFAIL_PAGE; for (int i = 0; i < notDisplayInEditPage.length; i++) {
String columnName = notDisplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CR_CreditRights, columnName);
columnDefinition.setDisplayInEditPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
}
for (int i = 0; i < notUseInDetailPage.length; i++) {
String columnName = notUseInDetailPage[i]; ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CR_CreditRights, columnName);
long columnId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> cccgds = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnId);
if (Validator.isNotNull(cccgds)) {
for (ColumnColumnGroupDefinition cccgd : cccgds) {
long columnGroupId = cccgd.getColumnGroupDefinitionId();
ColumnGroupDefinition columnGroup = ColumnGroupDefinitionLocalServiceUtil
.getColumnGroupDefinition(columnGroupId);
if (columnGroup.getGroupType() == 0) {
ColumnColumnGroupDefinitionLocalServiceUtil
.deleteColumnColumnGroupDefinition(cccgd);
}
}
}
} } private void initializingProjectColumn(long companyId) throws PortalException, SystemException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(TableConst.CRM_Project);
String[] projectTextType = ColumnConst.PROJECT_TEXT_TYPE;
String[] projectSelectType = ColumnConst.PROJECT_SELECT_TYPE;
String[] projectDateType = ColumnConst.PROJECT_DATE_TYPE;
String[] projectDoubleType = ColumnConst.PROJECT_DOUBLE_TYPE;
String[] projectTextareaType = ColumnConst.PROJECT_TEXTAREA_TYPE;
String[] projectPkType = ColumnConst.PROJECT_PK_TYPE;
String[] projectBooleanType = ColumnConst.PROJECT_BOOLEAN_TYPE; for (int i = 0; i < projectBooleanType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(projectBooleanType[i].substring(projectBooleanType[i].length() - 2));
String columnName = projectBooleanType[i].substring(0, projectBooleanType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Project, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("project." + columnName);
columnDefinition.setDefaultFormType(FormConst.boolean_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Project + " - " + columnName + " is exists...");
}
} for (int i = 0; i < projectPkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(projectPkType[i].substring(projectPkType[i].length() - 2));
String columnName = projectPkType[i].substring(0, projectPkType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Project, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("project." + columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Project + " - " + columnName + " is exists...");
}
} for (int i = 0; i < projectTextType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(projectTextType[i].substring(projectTextType[i].length() - 2));
String columnName = projectTextType[i].substring(0, projectTextType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Project, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("project." + columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Project + " - " + columnName + " is exists...");
}
} for (int i = 0; i < projectSelectType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(projectSelectType[i].substring(projectSelectType[i].length() - 2));
String columnName = projectSelectType[i].substring(0, projectSelectType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Project, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("project." + columnName);
columnDefinition.setDefaultFormType(FormConst.select);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Project + " - " + columnName + " is exists...");
}
} for (int i = 0; i < projectDateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(projectDateType[i].substring(projectDateType[i].length() - 2));
String columnName = projectDateType[i].substring(0, projectDateType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Project, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("project." + columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Project + " - " + columnName + " is exists...");
}
} for (int i = 0; i < projectDoubleType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(projectDoubleType[i].substring(projectDoubleType[i].length() - 2));
String columnName = projectDoubleType[i].substring(0, projectDoubleType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Project, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("project." + columnName);
columnDefinition.setDefaultFormType(FormConst.float_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Project + " - " + columnName + " is exists...");
}
} for (int i = 0; i < projectTextareaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(projectTextareaType[i].substring(projectTextareaType[i].length() - 2));
String columnName = projectTextareaType[i].substring(0, projectTextareaType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Project, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("project." + columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Project + " - " + columnName + " is exists...");
}
} this.initConfigField(tableDefinitionId, TableConst.CRM_Project); Locale locale = CompanyLocalServiceUtil.getCompany(companyId).getLocale();
ColumnGroupDefinition baseGroupColumn_Edit = createColumnGroup(TableConst.CRM_Project, locale, PC_COLUMN_GROUP_TYPE_EDIT, PortletPropsValues.COLUMN_GROUP_BASE);
ColumnGroupDefinition baseGroupColumn_Detail = createColumnGroup(TableConst.CRM_Project, locale, PC_COLUMN_GROUP_TYPE_DETAIL, PortletPropsValues.COLUMN_GROUP_BASE); List<ColumnColumnGroupDefinition> columnColumnGroup = ColumnColumnGroupDefinitionLocalServiceUtil
.searchByColumnGroupDefinitionId(baseGroupColumn_Detail.getColumnGroupDefinitionId());
if (!Validator.isNotNull(columnColumnGroup)) {
String[] baseGroupColumns = ColumnConst.PROJECT_BASE_GROUP_COLUMN;
for (int i = 0; i < baseGroupColumns.length; i++) {
String columnName = baseGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Project, columnName);
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(baseGroupColumn_Detail.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(baseGroupColumn_Edit.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInEditPage);
}
} String[] notDisplayInEditPage = ColumnConst.PROJECT_NOT_DISPLAY_IN_EDIT_PAGE;
for (int i = 0; i < notDisplayInEditPage.length; i++) {
String columnName = notDisplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Project, columnName);
columnDefinition.setDisplayInEditPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
} String[] notDisplayInDetailPage = ColumnConst.PROJECT_NOT_DISPLAY_IN_DETAIL_PAGE;
for (int i = 0; i < notDisplayInDetailPage.length; i++) {
String columnName = notDisplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Project, columnName);
columnDefinition.setDisplayInDetailPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
}
} private void initializingCustomerColumn(long companyId) throws SystemException, PortalException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(TableConst.CRM_Customer); String[] selectType = ColumnConst.CUSTOMER_SELECT_TYPE;
String[] textType = ColumnConst.CUSTOMER_TEXT_TYPE;
String[] pkType = ColumnConst.CUSTOMER_PK_TYPE;
String[] textareaType = ColumnConst.CUSTOMER_TEXTAREA_TYPE;
String[] dateType = ColumnConst.CUSTOMER_DATE_TYPE;
String[] floatType = ColumnConst.CUSTOMER_FLOAT_TYPE; for (int i = 0; i < selectType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(selectType[i].substring(selectType[i].length() - 2));
String columnName = selectType[i].substring(0, selectType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Customer, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("customer." + columnName);
columnDefinition.setDefaultFormType(FormConst.select);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Customer + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i].substring(textType[i].length() - 2));
String columnName = textType[i].substring(0,textType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Customer, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("customer." + columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("customerName") || columnName.equals("code")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
}
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Customer + " - " + columnName + " is exists...");
}
} for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i].substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0,pkType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Customer, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("customer." + columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Customer + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textareaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textareaType[i].substring(textareaType[i].length() - 2));
String columnName = textareaType[i].substring(0, textareaType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Customer, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition
.setDefaultDisplayName("customer." + columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Customer + " - " + columnName + " is exists...");
}
} for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i].substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0,dateType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Customer, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition
.setDefaultDisplayName("customer." + columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
columnDefinition.setTableDefinitionId(tableDefinitionId);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Customer + " - " + columnName + " is exists...");
}
} for (int i = 0; i < floatType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(floatType[i].substring(floatType[i].length() - 2));
String columnName = floatType[i].substring(0,floatType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Customer, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("customer." + columnName);
columnDefinition.setDefaultFormType(FormConst.float_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Customer + " - " + columnName + " is exists...");
}
} this.initConfigField(tableDefinitionId,TableConst.CRM_Customer); Locale locale = CompanyLocalServiceUtil.getCompany(companyId).getLocale();
ColumnGroupDefinition baseGroupColumn_Edit = createColumnGroup(TableConst.CRM_Customer, locale, PC_COLUMN_GROUP_TYPE_EDIT, PortletPropsValues.COLUMN_GROUP_BASE);
ColumnGroupDefinition baseGroupColumn_Detail = createColumnGroup(TableConst.CRM_Customer, locale, PC_COLUMN_GROUP_TYPE_DETAIL, PortletPropsValues.COLUMN_GROUP_BASE);
ColumnGroupDefinition contactGroupColumn_Edit = createColumnGroup(TableConst.CRM_Customer, locale, PC_COLUMN_GROUP_TYPE_EDIT, PortletPropsValues.COLUMN_GROUP_CONTACT);
ColumnGroupDefinition contactGroupColumn_Detail = createColumnGroup(TableConst.CRM_Customer, locale, PC_COLUMN_GROUP_TYPE_DETAIL, PortletPropsValues.COLUMN_GROUP_CONTACT); List<ColumnColumnGroupDefinition> columnColumnGroup = ColumnColumnGroupDefinitionLocalServiceUtil
.searchByColumnGroupDefinitionId(baseGroupColumn_Detail.getColumnGroupDefinitionId());
if (!Validator.isNotNull(columnColumnGroup)) {
String[] baseGroupColumns = ColumnConst.CUSTOMER_BASE_GROUP_COLUMNS;
for (int i = 0; i < baseGroupColumns.length; i++) {
String columnName = baseGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Customer, columnName);
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(baseGroupColumn_Detail.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(baseGroupColumn_Edit.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInEditPage);
} String[] contactGroupColumns = ColumnConst.CUSTOMER_CONTACT_GROUP_COLUMNS;
for (int i = 0; i < contactGroupColumns.length; i++) {
String columnName = contactGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Customer, columnName);
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(contactGroupColumn_Detail.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(contactGroupColumn_Edit.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInEditPage);
}
} String[] notUseInDetailPage = ColumnConst.CUSTOMER_NOT_USE_IN_DETAIL_PAGE;
for (int i = 0; i < notUseInDetailPage.length; i++) {
String columnName = notUseInDetailPage[i]; ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Customer, columnName);
long columnId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> cccgds = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnId);
if (Validator.isNotNull(cccgds)) {
for (ColumnColumnGroupDefinition cccgd : cccgds) {
long columnGroupId = cccgd.getColumnGroupDefinitionId();
ColumnGroupDefinition columnGroup = ColumnGroupDefinitionLocalServiceUtil
.getColumnGroupDefinition(columnGroupId);
if (columnGroup.getGroupType() == 0) {
ColumnColumnGroupDefinitionLocalServiceUtil
.deleteColumnColumnGroupDefinition(cccgd);
}
}
}
} ColumnGroupDefinition baseColumnGroup_edit_4_android = createGroup4Android(TableConst.CRM_Customer, locale, ANDROID_COLUMN_GROUP_TYPE_EDIT, PortletPropsValues.COLUMN_GROUP_BASE, 0);
ColumnGroupDefinition baseColumnGroup_detail_4_android = createGroup4Android(TableConst.CRM_Customer, locale, ANDROID_COLUMN_GROUP_TYPE_DETAIL, PortletPropsValues.COLUMN_GROUP_BASE, 0);
ColumnGroupDefinition contactColumnGroup_edit_4_android = createGroup4Android(TableConst.CRM_Customer, locale, ANDROID_COLUMN_GROUP_TYPE_EDIT, PortletPropsValues.COLUMN_GROUP_CONTACT, 1);
ColumnGroupDefinition contactColumnGroup_detail_4_android = createGroup4Android(TableConst.CRM_Customer, locale, ANDROID_COLUMN_GROUP_TYPE_DETAIL, PortletPropsValues.COLUMN_GROUP_CONTACT, 1); List<ColumnColumnGroupDefinition> baseGroupColumnEdit_android = ColumnColumnGroupDefinitionLocalServiceUtil
.searchByColumnGroupDefinitionId(baseColumnGroup_edit_4_android.getColumnGroupDefinitionId()); if (!Validator.isNotNull(baseGroupColumnEdit_android)) {
String[] baseGroupColumns = ColumnConst.CUSTOMER_BASE_GROUP_COLUMNS_4_ANDOIRD;
for (int i = 0; i < baseGroupColumns.length; i++) {
String columnName = baseGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Customer, columnName);
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(baseColumnGroup_detail_4_android.getColumnGroupDefinitionId());
columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(baseColumnGroup_edit_4_android.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInEditPage);
} String[] contactGroupColumns = ColumnConst.CUSTOMER_CONTACT_GROUP_COLUMNS_4_ANDOIRD;
for (int i = 0; i < contactGroupColumns.length; i++) {
String columnName = contactGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Customer, columnName);
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(contactColumnGroup_detail_4_android.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(contactColumnGroup_edit_4_android.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInEditPage);
}
} String[] notDisplayInEditPage = ColumnConst.CUSTOMER_NOT_DISPLAY_IN_EDIT_PAGE;
for (int i = 0; i < notDisplayInEditPage.length; i++) {
String columnName = notDisplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Customer, columnName);
columnDefinition.setDisplayInEditPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
}
} private void initializingContactColumn(long companyId) throws SystemException, PortalException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(TableConst.CRM_Contact); Company company = CompanyLocalServiceUtil.getCompany(companyId);
Locale locale = company.getLocale(); String[] dateType = ColumnConst.CONTACT_DATE_TYPE;
String[] selectType = ColumnConst.CONTACT_SELECT_TYPE;
String[] textType = ColumnConst.CONTACT_TEXT_TYPE;
String[] pkType = ColumnConst.CONTACT_PK_TYPE;
String[] textareaType = ColumnConst.CONTACT_TEXTAREA_TYPE; for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i].substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0, dateType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contact, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("contact." + columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Contact + " - " + columnName + " is exists...");
}
} for (int i = 0; i < selectType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(selectType[i].substring(selectType[i].length() - 2));
String columnName = selectType[i].substring(0, selectType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contact, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("contact." + columnName);
columnDefinition.setDefaultFormType(FormConst.select);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Contact + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i]
.substring(textType[i].length() - 2));
String columnName = textType[i].substring(0,
textType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contact, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("contact." + columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("contactName") || columnName.equals("appellation")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
}
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Contact + " - " + columnName + " is exists...");
}
} for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i].substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0,pkType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contact, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("contact." + columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Contact + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textareaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textareaType[i].substring(textareaType[i].length() - 2));
String columnName = textareaType[i].substring(0,textareaType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contact, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("contact." + columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition);
} else {
_log.info(TableConst.CRM_Contact + " - " + columnName + " is exists...");
}
} this.initConfigField(tableDefinitionId, TableConst.CRM_Contact);
ColumnGroupDefinition baseGroupColumn_Edit = createColumnGroup(TableConst.CRM_Contact, locale, PC_COLUMN_GROUP_TYPE_EDIT, PortletPropsValues.COLUMN_GROUP_BASE);
ColumnGroupDefinition baseGroupColumn_Detail = createColumnGroup(TableConst.CRM_Contact, locale, PC_COLUMN_GROUP_TYPE_DETAIL, PortletPropsValues.COLUMN_GROUP_BASE);
ColumnGroupDefinition contactGroupColumn_Edit = createColumnGroup(TableConst.CRM_Contact, locale, PC_COLUMN_GROUP_TYPE_EDIT, PortletPropsValues.COLUMN_GROUP_CONTACT);
ColumnGroupDefinition contactGroupColumn_Detail = createColumnGroup(TableConst.CRM_Contact, locale, PC_COLUMN_GROUP_TYPE_DETAIL, PortletPropsValues.COLUMN_GROUP_CONTACT); List<ColumnColumnGroupDefinition> columnColumnGroup = ColumnColumnGroupDefinitionLocalServiceUtil
.searchByColumnGroupDefinitionId(baseGroupColumn_Detail.getColumnGroupDefinitionId());
if (!Validator.isNotNull(columnColumnGroup)) {
String[] baseGroupColumns = ColumnConst.CONTACT_BASE_GROUP_COLUMNS;
for (int i = 0; i < baseGroupColumns.length; i++) {
String columnName = baseGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contact, columnName);
long columnDefinitionId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> columnColumnGroupDefinitions = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnDefinitionId);
if (!Validator.isNotNull(columnColumnGroupDefinitions)) {
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinitionId);
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(baseGroupColumn_Detail.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(baseGroupColumn_Edit.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInEditPage);
}
} String[] contactGroupColumns = ColumnConst.CONTACT_CONTACT_GROUP_COLUMNS;
for (int i = 0; i < contactGroupColumns.length; i++) {
String columnName = contactGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contact, columnName);
long columnDefinitionId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> columnColumnGroupDefinitions = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnDefinitionId);
if (!Validator.isNotNull(columnColumnGroupDefinitions)) {
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(contactGroupColumn_Detail.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(contactGroupColumn_Edit.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInEditPage);
}
}
} ColumnGroupDefinition baseColumnGroup_edit_4_android = createGroup4Android(TableConst.CRM_Contact, locale, ANDROID_COLUMN_GROUP_TYPE_EDIT, PortletPropsValues.COLUMN_GROUP_BASE ,0 );
ColumnGroupDefinition baseColumnGroup_detail_4_android = createGroup4Android(TableConst.CRM_Contact, locale, ANDROID_COLUMN_GROUP_TYPE_DETAIL, PortletPropsValues.COLUMN_GROUP_BASE, 0);
ColumnGroupDefinition contactColumnGroup_edit_4_android = createGroup4Android(TableConst.CRM_Contact, locale, ANDROID_COLUMN_GROUP_TYPE_EDIT, PortletPropsValues.COLUMN_GROUP_CONTACT, 1);
ColumnGroupDefinition contactColumnGroup_detail_4_android = createGroup4Android(TableConst.CRM_Contact, locale, ANDROID_COLUMN_GROUP_TYPE_DETAIL, PortletPropsValues.COLUMN_GROUP_CONTACT, 1); List<ColumnColumnGroupDefinition> baseGroupColumnEdit_android = ColumnColumnGroupDefinitionLocalServiceUtil
.searchByColumnGroupDefinitionId(baseColumnGroup_edit_4_android.getColumnGroupDefinitionId());
if (!Validator.isNotNull(baseGroupColumnEdit_android)) {
String[] baseGroupColumns = ColumnConst.CONTACT_BASE_GROUP_COLUMNS_4_ANDROID;
for (int i = 0; i < baseGroupColumns.length; i++) {
String columnName = baseGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contact, columnName);
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(baseColumnGroup_detail_4_android.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(baseColumnGroup_edit_4_android.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInEditPage);
} String[] contactGroupColumns = ColumnConst.CONTACT_GROUP_COLUMNS_4_ANDROID;
for (int i = 0; i < contactGroupColumns.length; i++) {
String columnName = contactGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contact, columnName);
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(contactColumnGroup_detail_4_android.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(contactColumnGroup_edit_4_android.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInEditPage);
}
} String[] notDisplayInEditPage = ColumnConst.CONTACT_NOT_DISPLAY_IN_EDIT_PAGE;
for (int i = 0; i < notDisplayInEditPage.length; i++) {
String columnName = notDisplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contact, columnName);
columnDefinition.setDisplayInEditPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
} String[] notDisplayInDetailPage = ColumnConst.CONTACT_NOT_USE_DISPLAY_IN_DETAIL_PAGE;
for (int i = 0; i < notDisplayInDetailPage.length; i++) {
String columnName = notDisplayInDetailPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contact, columnName);
long columnId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> cccgds = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnId);
if (Validator.isNotNull(cccgds)) {
for (ColumnColumnGroupDefinition cccgd : cccgds) {
long columnGroupId = cccgd.getColumnGroupDefinitionId();
ColumnGroupDefinition columnGroup = ColumnGroupDefinitionLocalServiceUtil
.getColumnGroupDefinition(columnGroupId);
if (columnGroup.getGroupType() == 0) {
ColumnColumnGroupDefinitionLocalServiceUtil
.deleteColumnColumnGroupDefinition(cccgd);
}
}
}
}
} private void initializingMarketColumn(long companyId) throws SystemException, PortalException { Company company = CompanyLocalServiceUtil.getCompany(companyId);
Locale locale = company.getLocale(); long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(TableConst.CRM_Market);
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION, locale, PortletPropsValues.COLUMN_GROUP_BASE); ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 0);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null){
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(0);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(PC_COLUMN_GROUP_TYPE_DETAIL);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil.updateColumnGroupDefinition(columnGroupInDetailPage);
} ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 1);
ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null){
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(0);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(PC_COLUMN_GROUP_TYPE_EDIT);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil.updateColumnGroupDefinition(columnGroupInEditPage);
} String[] dateType = ColumnConst.MARKET_DATE_TYPE;
String[] selectType = ColumnConst.MARKET_SELECT_TYPE;
String[] textType = ColumnConst.MARKET_TEXT_TYPE;
String[] floatType = ColumnConst.MARKET_FLOAT_TYPE;
String[] textareaType = ColumnConst.MARKET_TEXTAREA_TYPE;
String[] pkType = ColumnConst.MARKET_PK_TYPE;
String[] integerType = ColumnConst.MARKET_INTEGER_TYPE; for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i].substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0, dateType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Market, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("market."+columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
columnDefinition.setTableDefinitionId(tableDefinitionId);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Market + " - " + columnName + " is exists...");
}
} for (int i = 0; i < selectType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(selectType[i].substring(selectType[i].length() - 2));
String columnName = selectType[i].substring(0, selectType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Market, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("market."+columnName);
columnDefinition.setDefaultFormType(FormConst.select);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("channel")
|| columnName.equals("priority")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
} ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(), columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId()); } else {
_log.info(TableConst.CRM_Market + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i].substring(textType[i].length() - 2));
String columnName = textType[i].substring(0, textType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Market, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("market."+columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
if (columnName.equals("name") || columnName.equals("code")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
}
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(), columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Market + " - " + columnName + " is exists...");
}
} for (int i = 0; i < integerType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(integerType[i].substring(integerType[i].length() - 2));
String columnName = integerType[i].substring(0, integerType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Market, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("market."+columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
if (columnName.equals("name") || columnName.equals("code")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
}
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(), columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Market + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textareaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textareaType[i].substring(textareaType[i].length() - 2));
String columnName = textareaType[i].substring(0, textareaType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Market, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("market."+columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Market + " - " + columnName + " is exists...");
}
} for (int i = 0; i < floatType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(floatType[i].substring(floatType[i].length() - 2));
String columnName = floatType[i].substring(0, floatType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Market, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("market."+columnName);
columnDefinition.setDefaultFormType(FormConst.float_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
if (columnName.equals("planFees")) {
columnDefinition.setVerifyType(FormConst.VERIFY_FLOAT);
columnDefinition.setVerifyTips(PortletPropsValues.VERIFY_DIGIT_TIPS);
}
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Market + " - " + columnName + " is exists...");
}
} for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i].substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0, pkType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Market, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("market."+columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Market + " - " + columnName + " is exists...");
}
} this.initConfigField(tableDefinitionId,TableConst.CRM_Market); String[] notDisplayInEditPage = ColumnConst.MARKET_NOT_DISPLAY_IN_EDIT_PAGE;
String[] notUseInDetailPage = ColumnConst.MARKET_NOT_USE_IN_DETAIL_PAGE; for (int i = 0; i < notDisplayInEditPage.length; i++) {
String columnName = notDisplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Market, columnName);
columnDefinition.setDisplayInEditPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
}
for (int i = 0; i < notUseInDetailPage.length; i++) {
String columnName = notUseInDetailPage[i]; ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Market, columnName);
long columnId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> cccgds = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnId);
if (Validator.isNotNull(cccgds)) {
for (ColumnColumnGroupDefinition cccgd : cccgds) {
long columnGroupId = cccgd.getColumnGroupDefinitionId();
ColumnGroupDefinition columnGroup = ColumnGroupDefinitionLocalServiceUtil
.getColumnGroupDefinition(columnGroupId);
if (columnGroup.getGroupType() == 0) {
ColumnColumnGroupDefinitionLocalServiceUtil
.deleteColumnColumnGroupDefinition(cccgd);
}
}
}
}
} private void initializingClueColumn(long companyId) throws SystemException,
PortalException { Company company = CompanyLocalServiceUtil.getCompany(companyId);
Locale locale = company.getLocale(); long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(TableConst.CRM_Clue); String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION, locale, PortletPropsValues.COLUMN_GROUP_BASE); ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 0);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null) {
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(0);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(PC_COLUMN_GROUP_TYPE_DETAIL);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupInDetailPage);
} ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 1);
ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null) {
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(0);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(PC_COLUMN_GROUP_TYPE_EDIT);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupInEditPage);
} String[] dateType = ColumnConst.CLUE_DATE_TYPE;
String[] selectType = ColumnConst.CLUE_SELECT_TYPE;
String[] textType = ColumnConst.CLUE_TEXT_TYPE;
String[] textareaType = ColumnConst.CLUE_TEXTAREA_TYPE;
String[] pkType = ColumnConst.CLUE_PK_TYPE;
String[] floatType = ColumnConst.CLUE_FLOAT_TYPE; for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i].substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0,dateType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Clue, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("clue." + columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
columnDefinition.setTableDefinitionId(tableDefinitionId);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId()); } else {
_log.info(TableConst.CRM_Clue + " - " + columnName + " is exists...");
}
} for (int i = 0; i < selectType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(selectType[i].substring(selectType[i].length() - 2));
String columnName = selectType[i].substring(0, selectType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Clue, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("clue." + columnName);
columnDefinition.setDefaultFormType(FormConst.select);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("type")
|| columnName.equals("industryId")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
}
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Clue + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i].substring(textType[i].length() - 2));
String columnName = textType[i].substring(0,textType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Clue, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("clue." + columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("mobile")) {
columnDefinition.setVerifyType(FormConst.VERIFY_MOBILE);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_MOBLIE_TIPS);
} if (columnName.equals("code") || columnName.equals("name")
|| columnName.equals("customerName")
|| columnName.equals("contactName")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
}
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Clue + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textareaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textareaType[i].substring(textareaType[i].length() - 2));
String columnName = textareaType[i].substring(0, textareaType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Clue, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("clue." + columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Clue + " - " + columnName + " is exists...");
}
} for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i].substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0, pkType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Clue, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("clue." + columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Clue + " - " + columnName + " is exists...");
}
} for (int i = 0; i < floatType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(floatType[i].substring(floatType[i].length() - 2));
String columnName = floatType[i].substring(0,floatType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Clue, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("clue." + columnName);
columnDefinition.setDefaultFormType(FormConst.integer_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Clue + " - " + columnName + " is exists...");
}
} this.initConfigField(tableDefinitionId,TableConst.CRM_Clue); String[] notDisplayInEditPage=ColumnConst.CLUE_NOT_DISPLAY_IN_EDIT_PAGE; for (int i = 0; i < notDisplayInEditPage.length; i++) {
String columnName = notDisplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Clue, columnName);
columnDefinition.setDisplayInEditPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
} String[] notUseDisplayInDetailPage = ColumnConst.CLUE_NOT_USE_DISPLAY_IN_DETAIL_PAGE;
for (int i = 0; i < notUseDisplayInDetailPage.length; i++) {
String columnName = notUseDisplayInDetailPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Clue, columnName);
long columnId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> cccgds = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnId);
if (Validator.isNotNull(cccgds)) {
for (ColumnColumnGroupDefinition cccgd : cccgds) {
long columnGroupId = cccgd.getColumnGroupDefinitionId();
ColumnGroupDefinition columnGroup = ColumnGroupDefinitionLocalServiceUtil
.getColumnGroupDefinition(columnGroupId);
if (columnGroup.getGroupType() == 0) {
ColumnColumnGroupDefinitionLocalServiceUtil
.deleteColumnColumnGroupDefinition(cccgd);
}
}
}
} ColumnGroupDefinition baseColumnGroup_edit_4_android = createGroup4Android(TableConst.CRM_Clue, locale, ANDROID_COLUMN_GROUP_TYPE_EDIT, PortletPropsValues.COLUMN_GROUP_BASE, 0);
ColumnGroupDefinition baseColumnGroup_detail_4_android = createGroup4Android(TableConst.CRM_Clue, locale, ANDROID_COLUMN_GROUP_TYPE_DETAIL, PortletPropsValues.COLUMN_GROUP_BASE, 0);
ColumnGroupDefinition contactColumnGroup_edit_4_android = createGroup4Android(TableConst.CRM_Clue, locale, ANDROID_COLUMN_GROUP_TYPE_EDIT, PortletPropsValues.COLUMN_GROUP_CONTACT, 1);
ColumnGroupDefinition contactColumnGroup_detail_4_android = createGroup4Android(TableConst.CRM_Clue, locale, ANDROID_COLUMN_GROUP_TYPE_DETAIL, PortletPropsValues.COLUMN_GROUP_CONTACT, 1); List<ColumnColumnGroupDefinition> baseGroupColumnEdit_android = ColumnColumnGroupDefinitionLocalServiceUtil
.searchByColumnGroupDefinitionId(baseColumnGroup_edit_4_android.getColumnGroupDefinitionId()); if (!Validator.isNotNull(baseGroupColumnEdit_android)) {
String[] baseGroupColumns = ColumnConst.CLUE_BASE_GROUP_COLUMNS_4_ANDOIRD;
for (int i = 0; i < baseGroupColumns.length; i++) {
String columnName = baseGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Clue, columnName);
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(baseColumnGroup_detail_4_android.getColumnGroupDefinitionId());
columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(baseColumnGroup_edit_4_android.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInEditPage);
} String[] contactGroupColumns = ColumnConst.CLUE_CONTACT_GROUP_COLUMNS_4_ANDOIRD;
for (int i = 0; i < contactGroupColumns.length; i++) {
String columnName = contactGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Clue, columnName);
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(contactColumnGroup_detail_4_android.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(contactColumnGroup_edit_4_android.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInEditPage);
}
} this.doContactInfoGroup4Clue(locale, tableDefinitionId);
} private void initializingOpportuntiyColumn(long companyId) throws SystemException, PortalException { Company company = CompanyLocalServiceUtil.getCompany(companyId);
Locale locale = company.getLocale(); long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(TableConst.CRM_Opportunity); String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION,
locale, PortletPropsValues.COLUMN_GROUP_BASE);
ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 0);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null){
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(0);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(PC_COLUMN_GROUP_TYPE_DETAIL);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil.updateColumnGroupDefinition(columnGroupInDetailPage);
} ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 1);
ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null){
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(0);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(PC_COLUMN_GROUP_TYPE_EDIT);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil.updateColumnGroupDefinition(columnGroupInEditPage);
} String[] dateType = ColumnConst.OPPORTUNITY_DATE_TYPE;
String[] selectType = ColumnConst.OPPORTUNITY_SELECT_TYPE;
String[] textType = ColumnConst.OPPORTUNITY_TEXT_TYPE;
String[] textareaType = ColumnConst.OPPORTUNITY_TEXTAREA_TYPE;
String[] floatType = ColumnConst.OPPORTUNITY_FLOAT_TYPE;
String[] pkType = ColumnConst.OPPORTUNITY_PK_TYPE; for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i].substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0,dateType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Opportunity, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("opportunity." + columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
columnDefinition.setTableDefinitionId(tableDefinitionId);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Opportunity + " - " + columnName + " is exists...");
}
} for (int i = 0; i < selectType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(selectType[i].substring(selectType[i].length() - 2));
String columnName = selectType[i].substring(0, selectType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Opportunity, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("opportunity." + columnName);
columnDefinition.setDefaultFormType(FormConst.select);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("source")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
} ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Opportunity + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i].substring(textType[i].length() - 2));
String columnName = textType[i].substring(0,textType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Opportunity, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("opportunity." + columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("code") || columnName.equals("topic")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
}
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Opportunity + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textareaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textareaType[i].substring(textareaType[i].length() - 2));
String columnName = textareaType[i].substring(0, textareaType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Opportunity, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("opportunity." + columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("code") || columnName.equals("topic")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
}
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Opportunity + " - " + columnName + " is exists...");
}
} for (int i = 0; i < floatType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(floatType[i].substring(floatType[i].length() - 2));
String columnName = floatType[i].substring(0,floatType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Opportunity, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("opportunity." + columnName);
columnDefinition.setDefaultFormType(FormConst.float_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Opportunity + " - " + columnName + " is exists...");
}
} for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i].substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0, pkType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Opportunity, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("opportunity." + columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Opportunity + " - " + columnName + " is exists...");
}
} this.initConfigField(tableDefinitionId, TableConst.CRM_Opportunity); ColumnGroupDefinition columnGroup_edit_4_android = createGroup4Android(TableConst.CRM_Opportunity, locale, ANDROID_COLUMN_GROUP_TYPE_EDIT, PortletPropsValues.COLUMN_GROUP_BASE, 0);
ColumnGroupDefinition columnGroup_detail_4_android = createGroup4Android(TableConst.CRM_Opportunity, locale, ANDROID_COLUMN_GROUP_TYPE_DETAIL, PortletPropsValues.COLUMN_GROUP_BASE, 0); List<ColumnColumnGroupDefinition> baseGroupColumnEdit_android = ColumnColumnGroupDefinitionLocalServiceUtil
.searchByColumnGroupDefinitionId(columnGroup_edit_4_android.getColumnGroupDefinitionId());
if (!Validator.isNotNull(baseGroupColumnEdit_android)) {
String[] baseGroupColumns = ColumnConst.OPPORTUNITY_GROUP_COLUMNS_4_ANDROID;
for (int i = 0; i < baseGroupColumns.length; i++) {
String columnName = baseGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Opportunity, columnName);
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(columnGroup_detail_4_android.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(columnGroup_edit_4_android.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInEditPage);
}
} String[] notUseInEditPage = ColumnConst.OPPORTUNITY_NOT_DISPLAY_IN_EDIT_PAGE; for (int i = 0; i < notUseInEditPage.length; i++) {
String columnName = notUseInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Opportunity, columnName);
columnDefinition.setDisplayInEditPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
} String[] notDisplayInDetail = ColumnConst.OPPORTUNITY_NOT_USE_IN_DETAIL_PAGE; for (int i = 0; i < notDisplayInDetail.length; i++) {
String columnName = notDisplayInDetail[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Opportunity, columnName);
long columnId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> cccgds = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnId);
if (Validator.isNotNull(cccgds)) {
for (ColumnColumnGroupDefinition cccgd : cccgds) {
long columnGroupId = cccgd.getColumnGroupDefinitionId();
ColumnGroupDefinition columnGroup = ColumnGroupDefinitionLocalServiceUtil
.getColumnGroupDefinition(columnGroupId);
if (columnGroup.getGroupType() == 0) {
ColumnColumnGroupDefinitionLocalServiceUtil.deleteColumnColumnGroupDefinition(cccgd);
}
}
}
}
} private void initializingQuotationColumn(long companyId)
throws SystemException, PortalException { Company company = CompanyLocalServiceUtil.getCompany(companyId);
Locale locale = company.getLocale(); long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(TableConst.CRM_Quotation); String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION,
locale, PortletPropsValues.COLUMN_GROUP_BASE);
ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 0);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null){
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(0);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(PC_COLUMN_GROUP_TYPE_DETAIL);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupInDetailPage);
} ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 1);
ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null){
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(0);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(PC_COLUMN_GROUP_TYPE_EDIT);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupInEditPage);
} String[] dateType = ColumnConst.QUOTATION_DATE_TYPE;
String[] textType = ColumnConst.QUOTATION_TEXT_TYPE;
String[] textareaType = ColumnConst.QUOTATION_TEXTAREA_TYPE;
String[] floatType = ColumnConst.QUOTATION_FLOAT_TYPE;
String[] pkType = ColumnConst.QUOTATION_PK_TYPE; for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i].substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0,dateType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Quotation, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("quotation." + columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
columnDefinition.setTableDefinitionId(tableDefinitionId);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Quotation + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i].substring(textType[i].length() - 2));
String columnName = textType[i].substring(0,textType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Quotation, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("quotation." + columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("code") || columnName.equals("name")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
} if (columnName.equals("phone")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
} ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Quotation + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textareaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textareaType[i]
.substring(textareaType[i].length() - 2));
String columnName = textareaType[i].substring(0, textareaType[i]
.length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Quotation, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("quotation." + columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Quotation + " - " + columnName + " is exists...");
}
} for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i].substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0, pkType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Quotation, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("quotation." + columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("customerId")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
}
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Quotation + " - " + columnName + " is exists...");
}
} for (int i = 0; i < floatType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(floatType[i]
.substring(floatType[i].length() - 2));
String columnName = floatType[i].substring(0,
floatType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Quotation, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("quotation." + columnName);
columnDefinition.setDefaultFormType(FormConst.float_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Quotation + " - " + columnName + " is exists...");
}
} this.initConfigField(tableDefinitionId,TableConst.CRM_Quotation); String[] notDisplayInEditPage = ColumnConst.QUOTATION_NOT_DISPLAY_IN_EDIT_PAGE; for (int i = 0; i < notDisplayInEditPage.length; i++) {
String columnName = notDisplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Quotation, columnName);
columnDefinition.setDisplayInEditPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
} String[] notDisplayInDetail = ColumnConst.QUOTATION_NOT_USE_IN_DETAIL_PAGE; for (int i = 0; i < notDisplayInDetail.length; i++) {
String columnName = notDisplayInDetail[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Quotation, columnName); long columnId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> cccgds = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnId);
if (Validator.isNotNull(cccgds)) {
for (ColumnColumnGroupDefinition cccgd : cccgds) {
long columnGroupId = cccgd.getColumnGroupDefinitionId();
ColumnGroupDefinition columnGroup = ColumnGroupDefinitionLocalServiceUtil
.getColumnGroupDefinition(columnGroupId);
if (columnGroup.getGroupType() == 0) {
ColumnColumnGroupDefinitionLocalServiceUtil
.deleteColumnColumnGroupDefinition(cccgd);
}
}
}
}
} private void initializingOrderColumn(long companyId) throws SystemException, PortalException { Company company = CompanyLocalServiceUtil.getCompany(companyId);
Locale locale = company.getLocale(); long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(TableConst.CRM_Order); String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION,
locale, PortletPropsValues.COLUMN_GROUP_BASE);
ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 0);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null){
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(0);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(PC_COLUMN_GROUP_TYPE_DETAIL);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupInDetailPage);
} ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 1);
ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null){
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(0);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(PC_COLUMN_GROUP_TYPE_EDIT);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupInEditPage);
} String[] textType = ColumnConst.ORDER_TEXT_TYPE;
String[] dateType = ColumnConst.ORDER_DATE_TYPE;
String[] textareaType = ColumnConst.ORDER_TEXTAREA_TYPE;
String[] floatType = ColumnConst.ORDER_FLOAT_TYPE;
String[] pkType = ColumnConst.ORDER_PK_TYPE; for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i].substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0,dateType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Order, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("order." + columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
columnDefinition.setTableDefinitionId(tableDefinitionId);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Order + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i].substring(textType[i].length() - 2));
String columnName = textType[i].substring(0,textType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Order, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("order." + columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("code") || columnName.equals("name")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
} ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Order + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textareaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textareaType[i].substring(textareaType[i].length() - 2));
String columnName = textareaType[i].substring(0, textareaType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Order, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("order." + columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Order + " - " + columnName + " is exists...");
}
} for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i].substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0, pkType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Order, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("order." + columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("customerId")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
} ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Order + " - " + columnName + " is exists...");
}
} for (int i = 0; i < floatType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(floatType[i].substring(floatType[i].length() - 2));
String columnName = floatType[i].substring(0,
floatType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Order, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("order." + columnName);
columnDefinition.setDefaultFormType(FormConst.float_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Order + " - " + columnName + " is exists...");
}
} this.initConfigField(tableDefinitionId,TableConst.CRM_Order); String[] notDisplayInEditPage = ColumnConst.ORDER_NOT_DISPLAY_IN_EDIT_PAGE; for (int i = 0; i < notDisplayInEditPage.length; i++) {
String columnName = notDisplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Order, columnName);
columnDefinition.setDisplayInEditPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
} String[] notDisplayInDetail = ColumnConst.ORDER_NOT_USE_IN_DETAIL_PAGE; for (int i = 0; i < notDisplayInDetail.length; i++) {
String columnName = notDisplayInDetail[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Order, columnName);
long columnId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> cccgds = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnId);
if (Validator.isNotNull(cccgds)) {
for (ColumnColumnGroupDefinition cccgd : cccgds) {
long columnGroupId = cccgd.getColumnGroupDefinitionId();
ColumnGroupDefinition columnGroup = ColumnGroupDefinitionLocalServiceUtil
.getColumnGroupDefinition(columnGroupId);
if (columnGroup.getGroupType() == 0) {
ColumnColumnGroupDefinitionLocalServiceUtil
.deleteColumnColumnGroupDefinition(cccgd);
}
}
}
}
} private void initializingActivityColumn(long companyId)
throws SystemException, PortalException { long tableDefinitionId = TableDefinitionLocalServiceUtil
.searchByTableName(TableConst.CRM_Activity);
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Locale locale = company.getLocale();
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION,
locale, PortletPropsValues.COLUMN_GROUP_BASE);
ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil
.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 0);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null) {
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator
.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(0);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(PC_COLUMN_GROUP_TYPE_DETAIL);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupInDetailPage);
} ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil
.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 1);
ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null) {
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator
.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(0);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(PC_COLUMN_GROUP_TYPE_EDIT);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupInEditPage);
} String[] selectType = ColumnConst.ACTIVITY_SELECT_TYPE;
String[] textType = ColumnConst.ACTIVITY_TEXT_TYPE;
String[] textareaType = ColumnConst.ACTIVITY_TEXTAREA_TYPE;
String[] pkType = ColumnConst.ACTIVITY_PK_TYPE;
String[] dateType = ColumnConst.ACTIVITY_DATE_TYPE;
String[] unionType = ColumnConst.ACTIVITY_UNION_TYPE;
String[] booleanType = ColumnConst.ACTIVITY_BOOLEAN_TYPE; for (int i = 0; i < selectType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(selectType[i]
.substring(selectType[i].length() - 2));
String columnName = selectType[i].substring(0,
selectType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Activity, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator
.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition
.setDefaultDisplayName("activity." + columnName);
columnDefinition.setDefaultFormType(FormConst.select);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Activity + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i]
.substring(textType[i].length() - 2));
String columnName = textType[i].substring(0,
textType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Activity, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator
.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition
.setDefaultDisplayName("activity." + columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("name")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
} ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Activity + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textareaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textareaType[i]
.substring(textareaType[i].length() - 2));
String columnName = textareaType[i].substring(0,
textareaType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Activity, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator
.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition
.setDefaultDisplayName("activity." + columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Activity + " - " + columnName + " is exists...");
}
} for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i]
.substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0, pkType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Activity, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator
.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition
.setDefaultDisplayName("activity." + columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Activity + " - " + columnName + " is exists...");
}
} for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i]
.substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0,
dateType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Activity, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator
.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition
.setDefaultDisplayName("activity." + columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
columnDefinition.setTableDefinitionId(tableDefinitionId);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Activity + " - " + columnName + " is exists...");
}
} for (int i = 0; i < unionType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(unionType[i]
.substring(unionType[i].length() - 2));
String columnName = unionType[i].substring(0,
unionType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Activity, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator
.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition
.setDefaultDisplayName("activity." + columnName);
columnDefinition.setDefaultFormType(FormConst.union);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
columnDefinition.setTableDefinitionId(tableDefinitionId);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Activity + " - " + columnName + " is exists...");
}
} for (int i = 0; i < booleanType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(booleanType[i]
.substring(booleanType[i].length() - 2));
String columnName = booleanType[i].substring(0,
booleanType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Activity, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator
.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition
.setDefaultDisplayName("activity." + columnName);
columnDefinition.setDefaultFormType(FormConst.boolean_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
columnDefinition.setTableDefinitionId(tableDefinitionId);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Activity + " - " + columnName + " is exists...");
}
} this.initConfigField(tableDefinitionId, TableConst.CRM_Activity); ColumnGroupDefinition columnGroup_edit_4_android = createGroup4Android(TableConst.CRM_Activity, locale, ANDROID_COLUMN_GROUP_TYPE_EDIT, PortletPropsValues.COLUMN_GROUP_BASE, 0);
ColumnGroupDefinition columnGroup_detail_4_android = createGroup4Android(TableConst.CRM_Activity, locale, ANDROID_COLUMN_GROUP_TYPE_DETAIL, PortletPropsValues.COLUMN_GROUP_BASE, 0); List<ColumnColumnGroupDefinition> baseGroupColumnEdit_android = ColumnColumnGroupDefinitionLocalServiceUtil
.searchByColumnGroupDefinitionId(columnGroup_edit_4_android.getColumnGroupDefinitionId());
if (!Validator.isNotNull(baseGroupColumnEdit_android)) {
String[] baseGroupColumns = ColumnConst.ACTIVITY_GROUP_COLUMNS_4_ANDROID;
for (int i = 0; i < baseGroupColumns.length; i++) {
String columnName = baseGroupColumns[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Activity, columnName);
ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(columnGroup_detail_4_android.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnDefinition.getColumnDefinitionId());
columnColumnGroupInEditPage.setColumnGroupDefinitionId(columnGroup_edit_4_android.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroupInEditPage);
}
} String[] notDisplayInEditPage = ColumnConst.ACTIVITY_NOT_DISPLAY_IN_EDIT_PAGE;
for (int i = 0; i < notDisplayInEditPage.length; i++) {
String columnName = notDisplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Activity, columnName);
columnDefinition.setDisplayInEditPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(
columnDefinition, true);
} String[] notUseInDetailPage = ColumnConst.ACTIVITY_NOT_USE_IN_DETAIL_PAGE;
for (int i = 0; i < notUseInDetailPage.length; i++) {
String columnName = notUseInDetailPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Activity, columnName);
long columnId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> cccgds = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnId);
if (Validator.isNotNull(cccgds)) {
for (ColumnColumnGroupDefinition cccgd : cccgds) {
long columnGroupId = cccgd.getColumnGroupDefinitionId();
ColumnGroupDefinition columnGroup = ColumnGroupDefinitionLocalServiceUtil
.getColumnGroupDefinition(columnGroupId);
if (columnGroup.getGroupType() == 0) {
ColumnColumnGroupDefinitionLocalServiceUtil
.deleteColumnColumnGroupDefinition(cccgd);
}
}
}
}
} private void initializingProductColumn(long companyId) throws SystemException, PortalException { long tableDefinitionId = TableDefinitionLocalServiceUtil
.searchByTableName(TableConst.CRM_Product);
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Locale locale = company.getLocale();
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION,
locale, PortletPropsValues.COLUMN_GROUP_BASE);
ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 0);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null){
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(0);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(PC_COLUMN_GROUP_TYPE_DETAIL);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupInDetailPage);
}
ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 1);
ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null){
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(0);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(PC_COLUMN_GROUP_TYPE_EDIT);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupInEditPage);
} String[] selectType = ColumnConst.PRODUCT_SELECT_TYPE;
String[] textType = ColumnConst.PRODUCT_TEXT_TYPE;
String[] textareaType = ColumnConst.PRODUCT_TEXTAREA_TYPE;
String[] pkType = ColumnConst.PRODUCT_PK_TYPE;
String[] floatType = ColumnConst.PRODUCT_FLOAT_TYPE;
String[] dateType = ColumnConst.PRODUCT_DATE_TYPE; for (int i = 0; i < selectType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(selectType[i]
.substring(selectType[i].length() - 2));
String columnName = selectType[i].substring(0, selectType[i]
.length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Product, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("product." + columnName);
columnDefinition.setDefaultFormType(FormConst.select);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Product + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i]
.substring(textType[i].length() - 2));
String columnName = textType[i].substring(0,
textType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Product, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("product." + columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("productName")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
} ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Product + " - " + columnName + " is exists...");
}
} for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i] .substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0,
pkType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Product, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("product." + columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
}
} for (int i = 0; i < textareaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textareaType[i].substring(textareaType[i].length() - 2));
String columnName = textareaType[i].substring(0, textareaType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Product, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("product." + columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Product + " - " + columnName + " is exists...");
}
} for (int i = 0; i < floatType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(floatType[i].substring(floatType[i].length() - 2));
String columnName = floatType[i].substring(0, floatType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Product, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("product." + columnName);
columnDefinition.setDefaultFormType(FormConst.float_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId());
_log.info("Add " + TableConst.CRM_Product + " - " + columnName + " is successfull...");
} else {
_log.info(TableConst.CRM_Product + " - " + columnName + " is exists...");
}
} for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i].substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0, dateType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Product, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("product." + columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Product + " - " + columnName + " is exists...");
}
} String[] notDiaplayInEditPage = ColumnConst.PRODUCT_NOT_DISPLAY_IN_EDIT_PAGE;
for (int i = 0; i < notDiaplayInEditPage.length; i++) {
String columnName = notDiaplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Product, columnName);
columnDefinition.setDisplayInEditPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
} String[] notDiaplayInDetailPage = ColumnConst.PRODUCT_NOT_USE_IN_DETAIL_PAGE;
for (int i = 0; i < notDiaplayInDetailPage.length; i++) {
String columnName = notDiaplayInDetailPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Product, columnName); long columnId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> cccgds = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnId);
if (Validator.isNotNull(cccgds)) {
for (ColumnColumnGroupDefinition cccgd : cccgds) {
long columnGroupId = cccgd.getColumnGroupDefinitionId();
ColumnGroupDefinition columnGroup = ColumnGroupDefinitionLocalServiceUtil
.getColumnGroupDefinition(columnGroupId);
if (columnGroup.getGroupType() == 0) {
ColumnColumnGroupDefinitionLocalServiceUtil
.deleteColumnColumnGroupDefinition(cccgd);
}
}
}
} this.initConfigField(tableDefinitionId,TableConst.CRM_Product);
} private void initializingContractColumn(long companyId) throws SystemException, PortalException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(TableConst.CRM_Contract); Company company = CompanyLocalServiceUtil.getCompany(companyId);
Locale locale = company.getLocale();
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION,locale, PortletPropsValues.COLUMN_GROUP_BASE);
ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 0);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null){
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(0);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(PC_COLUMN_GROUP_TYPE_DETAIL);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil.updateColumnGroupDefinition(columnGroupInDetailPage);
} ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 1);
ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null){ columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(0);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(PC_COLUMN_GROUP_TYPE_EDIT);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil.updateColumnGroupDefinition(columnGroupInEditPage);
} String[] textType = ColumnConst.CONTRACT_TEXT_TYPE;
String[] pkType = ColumnConst.CONTRACT_PK_TYPE;
String[] dateType = ColumnConst.CONTRACT_DATE_TYPE;
String[] textareaType = ColumnConst.CONTRACT_TEXTAREA_TYPE;
String[] selectType = ColumnConst.CONTRACT_SELECT_TYPE;
String[] doubleType = ColumnConst.CONTRACT_DOUBLE_TYPE; for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i].substring(textType[i].length() - 2));
String columnName = textType[i].substring(0,textType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contract, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("contract." + columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("title") || columnName.equals("code")
|| columnName.equals("amount")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
}
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Contract + " - " + columnName + " is exists...");
}
} for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i].substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0,pkType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contract, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("contract." + columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("customerId")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition
.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
} ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Contract + " - " + columnName + " is exists...");
}
} for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i].substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0,dateType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contract, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("contract." + columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
columnDefinition.setTableDefinitionId(tableDefinitionId);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Contract + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textareaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textareaType[i].substring(textareaType[i].length() - 2));
String columnName = textareaType[i].substring(0, textareaType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contract, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("contract." + columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Contract + " - " + columnName + " is exists...");
}
} for (int i = 0; i < selectType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(selectType[i].substring(selectType[i].length() - 2));
String columnName = selectType[i].substring(0, selectType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contract, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("contract." + columnName);
columnDefinition.setDefaultFormType(FormConst.select);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Contract + " - " + columnName + " is exists...");
}
} for (int i = 0; i < doubleType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(doubleType[i].substring(doubleType[i].length() - 2));
String columnName = doubleType[i].substring(0, doubleType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_Contract, columnName);
if (entity == null) { ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("contract." + columnName);
columnDefinition.setDefaultFormType(FormConst.double_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_Contract + " - " + columnName + " is exists...");
}
} this.initConfigField(tableDefinitionId, TableConst.CRM_Contract); String[] notDisplayInEditPage = ColumnConst.CONTRACT_NOT_DISPLAY_IN_EDIT_PAGE;
for (int i = 0; i < notDisplayInEditPage.length; i++) {
String columnName = notDisplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Contract, columnName);
columnDefinition.setDisplayInEditPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
} String[] notDisplayInDetailPage = ColumnConst.CONTRACT_NOT_USE_IN_DETAIL_PAGE;
for (int i = 0; i < notDisplayInDetailPage.length; i++) {
String columnName = notDisplayInDetailPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Contract, columnName); long columnId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> cccgds = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnId);
if (Validator.isNotNull(cccgds)) {
for (ColumnColumnGroupDefinition cccgd : cccgds) {
long columnGroupId = cccgd.getColumnGroupDefinitionId();
ColumnGroupDefinition columnGroup = ColumnGroupDefinitionLocalServiceUtil
.getColumnGroupDefinition(columnGroupId);
if (columnGroup.getGroupType() == 0) {
ColumnColumnGroupDefinitionLocalServiceUtil
.deleteColumnColumnGroupDefinition(cccgd);
}
}
}
}
} private void initializingOperatorColumn(long companyId) throws SystemException, PortalException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(TableConst.OPERATOR_Operator); String[] textType = ColumnConst.OPERATOR_TEXT_TYPE;
String[] dateType = ColumnConst.OPERATOR_DATE_TYPE;
String[] pkType = ColumnConst.OPERATOR_PK_TYPE; for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i].substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0, pkType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.OPERATOR_Operator, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("operator." + columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition);
}
} for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i].substring(textType[i].length() - 2));
String columnName = textType[i].substring(0,textType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.OPERATOR_Operator, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("operator." + columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition);
}
}
for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i].substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0,dateType[i].length() - 2); ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.OPERATOR_Operator, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("operator." + columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
columnDefinition.setTableDefinitionId(tableDefinitionId);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
}
} private void initializingRPlan(long companyId) throws SystemException, PortalException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(TableConst.CRM_RPLAN);
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Locale locale = company.getLocale();
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION,
locale, PortletPropsValues.COLUMN_GROUP_BASE);
ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 0);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null){
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(0);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(PC_COLUMN_GROUP_TYPE_DETAIL);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupInDetailPage);
}
ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 1);
ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null){
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(0);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(PC_COLUMN_GROUP_TYPE_EDIT);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupInEditPage);
} String[] textType = ColumnConst.RPLAN_TEXT_TYPE;
String[] dateType = ColumnConst.RPLAN_DATE_TYPE;
String[] pkType = ColumnConst.RPLAN_PK_TYPE;
String[] floatType = ColumnConst.RPLAN_FLOAT_TYPE;
String[] selectType = ColumnConst.RPLAN_SELECT_TYPE;
String[] textAreaType = ColumnConst.RPLAN_TEXTAREA_TYPE;
for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i].substring(textType[i].length() - 2));
String columnName = textType[i].substring(0,textType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_RPLAN, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("receivablesPlan." + columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("receivablesPlanCode")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
} ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_RPLAN + " - " + columnName + " is exists...");
}
} for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i].substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0,dateType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_RPLAN, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("receivablesPlan." + columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_RPLAN + " - " + columnName + " is exists...");
}
} for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i].substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0,pkType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_RPLAN, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("receivablesPlan." + columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("customerId") || columnName.equals("orderId")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
} ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_RPLAN + " - " + columnName + " is exists...");
}
} for (int i = 0; i < floatType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(floatType[i].substring(floatType[i].length() - 2));
String columnName = floatType[i].substring(0,floatType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_RPLAN, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("receivablesPlan." + columnName);
columnDefinition.setDefaultFormType(FormConst.float_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_RPLAN + " - " + columnName + " is exists...");
}
} for (int i = 0; i < selectType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(selectType[i].substring(selectType[i].length() - 2));
String columnName = selectType[i].substring(0,selectType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_RPLAN, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("receivablesPlan." + columnName);
columnDefinition.setDefaultFormType(FormConst.select);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_RPLAN + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textAreaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textAreaType[i].substring(textAreaType[i].length() - 2));
String columnName = textAreaType[i].substring(0,textAreaType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_RPLAN, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("receivablesPlan." + columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_RPLAN + " - " + columnName + " is exists...");
}
} String[] notDisplayInEditPage = ColumnConst.RPLAN_NOT_DISPLAY_IN_EDIT_PAGE;
for (int i = 0; i < notDisplayInEditPage.length; i++) {
String columnName = notDisplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_RPLAN, columnName);
columnDefinition.setDisplayInEditPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
} // String[] notDisplayInDetailPage = ColumnConst.RPLAN_NOT_DISPLAY_IN_DETAIL_PAGE;
// for (int i = 0; i < notDisplayInDetailPage.length; i++) {
// String columnName = notDisplayInDetailPage[i];
// ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_RPLAN, columnName);
// columnDefinition.setDisplayInDetailPage(false);
// ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
// } String[] notUseInDetailPage = ColumnConst.RPLAN_NOT_USE_IN_DETAIL_PAGE;
for (int i = 0; i < notUseInDetailPage.length; i++) {
String columnName = notUseInDetailPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_RPLAN, columnName); long columnId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> cccgds = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnId);
if (Validator.isNotNull(cccgds)) {
for (ColumnColumnGroupDefinition cccgd : cccgds) {
long columnGroupId = cccgd.getColumnGroupDefinitionId();
ColumnGroupDefinition columnGroup = ColumnGroupDefinitionLocalServiceUtil
.getColumnGroupDefinition(columnGroupId);
if (columnGroup.getGroupType() == 0) {
ColumnColumnGroupDefinitionLocalServiceUtil
.deleteColumnColumnGroupDefinition(cccgd);
}
}
}
}
} private void initializingRRecord(long companyId) throws SystemException, PortalException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(TableConst.CRM_RRECORD);
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Locale locale = company.getLocale();
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION,
locale, PortletPropsValues.COLUMN_GROUP_BASE);
ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(
groupDisplayName, tableDefinitionId, 0);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null){
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(0);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(PC_COLUMN_GROUP_TYPE_DETAIL);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupInDetailPage);
}
ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(groupDisplayName, tableDefinitionId, 1);
ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null){
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(0);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(PC_COLUMN_GROUP_TYPE_EDIT);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupInEditPage);
}
String[] textType = ColumnConst.RRECORD_TEXT_TYPE;
String[] dateType = ColumnConst.RRECORD_DATE_TYPE;
String[] pkType = ColumnConst.RRECORD_PK_TYPE;
String[] floatType = ColumnConst.RRECORD_FLOAT_TYPE;
String[] textareaType = ColumnConst.RRECORD_TEXTAREA_TYPE;
for (int i = 0; i < textType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textType[i].substring(textType[i].length() - 2));
String columnName = textType[i].substring(0,textType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(
TableConst.CRM_RRECORD, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("receivablesRecord." + columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1);
if (columnName.equals("receivablesRecordCode")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
}
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId()); } else {
_log.info(TableConst.CRM_RRECORD + " - " + columnName + " is exists...");
}
} for (int i = 0; i < dateType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(dateType[i].substring(dateType[i].length() - 2));
String columnName = dateType[i].substring(0,dateType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(
TableConst.CRM_RRECORD, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("receivablesRecord." + columnName);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition);
this.addColumnGroup(columnDefinition.getColumnDefinitionId(),columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId()); } else {
_log.info(TableConst.CRM_RRECORD + " - " + columnName + " is exists...");
}
} for (int i = 0; i < pkType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(pkType[i].substring(pkType[i].length() - 2));
String columnName = pkType[i].substring(0,pkType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_RRECORD, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("receivablesRecord." + columnName);
columnDefinition.setDefaultFormType(FormConst.pk);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); if (columnName.equals("customerId")) {
columnDefinition.setVerifyType(FormConst.VERIFY_NOT_NULL);
columnDefinition.setVerifyTips(PortletPropsValues.VERIFY_NOT_NULL_TIPS);
} ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_RRECORD + " - " + columnName + " is exists...");
}
} for (int i = 0; i < floatType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(floatType[i].substring(floatType[i].length() - 2));
String columnName = floatType[i].substring(0,floatType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_RRECORD, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("receivablesRecord." + columnName);
columnDefinition.setDefaultFormType(FormConst.float_);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition); this.addColumnGroup(columnDefinition.getColumnDefinitionId(),columnGroupInEditPage.getColumnGroupDefinitionId(),columnGroupInDetailPage.getColumnGroupDefinitionId()); } else {
_log.info(TableConst.CRM_RRECORD + " - " + columnName + " is exists...");
}
} for (int i = 0; i < textareaType.length; i++) {
int defaultDisplayIndex = Integer.valueOf(textareaType[i].substring(textareaType[i].length() - 2));
String columnName = textareaType[i].substring(0,textareaType[i].length() - 2);
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(TableConst.CRM_RRECORD, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultDisplayName("receivablesRecord." + columnName);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setDefaultDisplayIndex(defaultDisplayIndex);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(DISPALY_1);
columnDefinition.setDisplayInEditPage(DISPALY_1);
columnDefinition.setIsDisplayInPage(DISPALY_1); ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition);
this.addColumnGroup(columnDefinition.getColumnDefinitionId(),
columnGroupInEditPage.getColumnGroupDefinitionId(),
columnGroupInDetailPage.getColumnGroupDefinitionId());
} else {
_log.info(TableConst.CRM_RRECORD + " - " + columnName + " is exists...");
}
} String[] notDisplayInEditPage = ColumnConst.RRECORD_NOT_DISPLAY_IN_EDIT_PAGE;
for (int i = 0; i < notDisplayInEditPage.length; i++) {
String columnName = notDisplayInEditPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(
TableConst.CRM_RRECORD, columnName);
columnDefinition.setDisplayInEditPage(false);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition, true);
} String[] notDisplayInDetailPage = ColumnConst.RRECORD_NOT_USE_IN_DETAIL_PAGE;
for (int i = 0; i < notDisplayInDetailPage.length; i++) {
String columnName = notDisplayInDetailPage[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil.searchByColumnName(
TableConst.CRM_RRECORD, columnName); long columnId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> cccgds = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnId);
if (Validator.isNotNull(cccgds)) {
for (ColumnColumnGroupDefinition cccgd : cccgds) {
long columnGroupId = cccgd.getColumnGroupDefinitionId();
ColumnGroupDefinition columnGroup = ColumnGroupDefinitionLocalServiceUtil
.getColumnGroupDefinition(columnGroupId);
if (columnGroup.getGroupType() == 0) {
ColumnColumnGroupDefinitionLocalServiceUtil
.deleteColumnColumnGroupDefinition(cccgd);
}
}
}
}
} private void initConfigField(long tableDefinitionId, String tableName) throws SystemException, NoSuchTableDefinitionException{
if (tableName.equals(TableConst.CRM_Customer) || tableName.equals(TableConst.CRM_Product) || tableName.equals(TableConst.CRM_Contract)) {
for (int i = 1; i < 11; i++) {
String columnName = "strField" + i;
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(tableName, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(false);
columnDefinition.setDisplayInEditPage(false);
columnDefinition.setIsDisplayInPage(false);
columnDefinition.setIsCustom(true);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
}
} else {
for (int i = 1; i < 9; i++) {
String columnName = "strField" + i;
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(tableName, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultFormType(FormConst.text);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(false);
columnDefinition.setDisplayInEditPage(false);
columnDefinition.setIsDisplayInPage(false);
columnDefinition.setIsCustom(true);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
}
} if (tableName.equals(TableConst.CRM_Customer) || tableName.equals(TableConst.CRM_Product) || tableName.equals(TableConst.CRM_Contact) || tableName.equals(TableConst.CRM_Contract)) {
for (int i = 1; i < 5; i++) {
String columnName = "textareaField" + i;
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(tableName, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName("textareaField" + i);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(false);
columnDefinition.setDisplayInEditPage(false);
columnDefinition.setIsDisplayInPage(false);
columnDefinition.setIsCustom(true);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
}
} else {
for (int i = 1; i < 3; i++) {
String columnName = "textareaField" + i;
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(tableName, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName("textareaField" + i);
columnDefinition.setDefaultFormType(FormConst.textarea);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(false);
columnDefinition.setDisplayInEditPage(false);
columnDefinition.setIsDisplayInPage(false);
columnDefinition.setIsCustom(true);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
}
} for (int i = 1; i < 5; i++) {
String columnName = "floatField" + i;
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(tableName, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName("floatField" + i);
columnDefinition.setDefaultFormType(FormConst.float_);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(false);
columnDefinition.setDisplayInEditPage(false);
columnDefinition.setIsDisplayInPage(false);
columnDefinition.setIsCustom(true);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
} for (int i = 1; i < 5; i++) {
String columnName = "dateField" + i;
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(tableName, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName("dateField" + i);
columnDefinition.setDefaultFormType(FormConst.date);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(false);
columnDefinition.setDisplayInEditPage(false);
columnDefinition.setIsDisplayInPage(false);
columnDefinition.setIsCustom(true);
ColumnDefinitionLocalServiceUtil.updateColumnDefinition(columnDefinition);
}
} if (tableName.equals(TableConst.CRM_Customer)) {
for (int i = 1; i < 5; i++) {
String columnName = "integerField" + i;
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(tableName, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultFormType(FormConst.integer_);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(false);
columnDefinition.setDisplayInEditPage(false);
columnDefinition.setIsDisplayInPage(false);
columnDefinition.setIsCustom(true);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
}
} else {
for (int i = 1; i < 3; i++) {
String columnName = "integerField" + i;
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(tableName, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultFormType(FormConst.integer_);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(false);
columnDefinition.setDisplayInEditPage(false);
columnDefinition.setIsDisplayInPage(false);
columnDefinition.setIsCustom(true);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
}
} if (tableName.equals(TableConst.CRM_Contact) || tableName.equals(TableConst.CRM_Customer) ||
tableName.equals(TableConst.CRM_Activity) || tableName.equals(TableConst.CRM_Product) ||
tableName.equals(TableConst.CRM_Contract) || tableName.equals(TableConst.CRM_Clue) ||
tableName.equals(TableConst.CRM_Market) || tableName.equals(TableConst.CRM_Opportunity) ||
tableName.equals(TableConst.CRM_Quotation) || tableName.equals(TableConst.CRM_Order)) {
for (int i = 1; i < 3; i++) {
String columnName = "attaField" + i;
ColumnDefinition entity = ColumnDefinitionLocalServiceUtil.searchByColumnName(tableName, columnName);
if (entity == null) {
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.createColumnDefinition(IDGenerator.increment(ColumnDefinition.class.getName()));
columnDefinition.setColumnName(columnName);
columnDefinition.setDefaultFormType(FormConst.attachment);
columnDefinition.setTableDefinitionId(tableDefinitionId);
columnDefinition.setDisplayInDetailPage(false);
columnDefinition.setDisplayInEditPage(false);
columnDefinition.setIsDisplayInPage(false);
columnDefinition.setIsCustom(true);
ColumnDefinitionLocalServiceUtil
.updateColumnDefinition(columnDefinition);
}
}
}
} private void addColumnGroup(Long columnId, Long columnEditGroupId, Long columnDetailGroupId) throws SystemException { ColumnColumnGroupDefinition columnColumnGroupInDetailPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInDetailPage.setColumnDefinitionId(columnId);
columnColumnGroupInDetailPage.setColumnGroupDefinitionId(columnEditGroupId);
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInDetailPage); ColumnColumnGroupDefinition columnColumnGroupInEditPage = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroupInEditPage.setColumnDefinitionId(columnId);
columnColumnGroupInEditPage.setColumnGroupDefinitionId(columnDetailGroupId);
ColumnColumnGroupDefinitionLocalServiceUtil.addColumnColumnGroupDefinition(columnColumnGroupInEditPage);
} private ColumnGroupDefinition createColumnGroup(
String tableName, Locale locale, int groupType, String groupName) throws PortalException, SystemException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(tableName);
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION, locale, groupName);
ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(tableDefinitionId, groupDisplayName, groupType);
ColumnGroupDefinition columnGroupInDetailPage = columnDetailGroup;
if (columnDetailGroup == null){
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInDetailPage.setDisplayIndex(1);
columnGroupInDetailPage.setIsDisplay(DISPALY_1);
columnGroupInDetailPage.setGroupDisplayName(groupDisplayName);
columnGroupInDetailPage.setTableDefinitionId(tableDefinitionId);
columnGroupInDetailPage.setGroupType(groupType);
columnGroupInDetailPage = ColumnGroupDefinitionLocalServiceUtil.addColumnGroupDefinition(columnGroupInDetailPage);
}
return columnGroupInDetailPage;
} private ColumnGroupDefinition createGroup4Android(String tableName,
Locale locale, int groupTpye, String groupName, int displayIndex)
throws SystemException, NoSuchTableDefinitionException {
long tableDefinitionId = TableDefinitionLocalServiceUtil.searchByTableName(tableName);
String groupDisplayName = LanguageUtil.get(PortletIDs.INITIALIZATION, locale, groupName); ColumnGroupDefinition columnEditGroup = ColumnGroupDefinitionLocalServiceUtil
.searchGroupDisplayName(tableDefinitionId, groupDisplayName, groupTpye); ColumnGroupDefinition columnGroupInEditPage = columnEditGroup;
if (columnEditGroup == null) {
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupInEditPage.setDisplayIndex(displayIndex);
columnGroupInEditPage.setIsDisplay(DISPALY_1);
columnGroupInEditPage.setGroupDisplayName(groupDisplayName);
columnGroupInEditPage.setTableDefinitionId(tableDefinitionId);
columnGroupInEditPage.setGroupType(groupTpye);
columnGroupInEditPage = ColumnGroupDefinitionLocalServiceUtil.addColumnGroupDefinition(columnGroupInEditPage);
} return columnGroupInEditPage;
} private void doContactInfoGroup4Clue(Locale locale, long tableDefinitionId) throws SystemException, PortalException {
String contactGroupName = LanguageUtil.get(PortletIDs.INITIALIZATION, locale, "column.group.contact");
ColumnGroupDefinition columnDetailGroup = ColumnGroupDefinitionLocalServiceUtil.searchGroupDisplayName(contactGroupName, tableDefinitionId, 1);
if (columnDetailGroup == null){
ColumnGroupDefinition columnGroupContact = ColumnGroupDefinitionLocalServiceUtil
.createColumnGroupDefinition(IDGenerator.increment(ColumnGroupDefinition.class.getName()));
columnGroupContact.setDisplayIndex(1);
columnGroupContact.setIsDisplay(DISPALY_1);
columnGroupContact.setGroupDisplayName(contactGroupName);
columnGroupContact.setTableDefinitionId(tableDefinitionId);
columnGroupContact.setGroupType(PC_COLUMN_GROUP_TYPE_EDIT);
columnGroupContact = ColumnGroupDefinitionLocalServiceUtil
.updateColumnGroupDefinition(columnGroupContact); String[] columnArray = new String[] { "phone", "mobile","fax", "email", "webSite", "country", "province", "city", "area", "address"};
for (int i = 0; i < columnArray.length; i++) {
String columnName = columnArray[i];
ColumnDefinition columnDefinition = ColumnDefinitionLocalServiceUtil
.searchByColumnName(TableConst.CRM_Clue, columnName);
long columnId = columnDefinition.getColumnDefinitionId();
List<ColumnColumnGroupDefinition> cccgds = ColumnColumnGroupDefinitionLocalServiceUtil.searchByColumnDefinitionId(columnId);
if (Validator.isNotNull(cccgds)) {
for (ColumnColumnGroupDefinition cccgd : cccgds) {
long columnGroupId = cccgd.getColumnGroupDefinitionId();
ColumnGroupDefinition columnGroup = ColumnGroupDefinitionLocalServiceUtil
.getColumnGroupDefinition(columnGroupId);
if (columnGroup.getGroupType() == 1) {
ColumnColumnGroupDefinitionLocalServiceUtil
.deleteColumnColumnGroupDefinition(cccgd);
}
}
} ColumnColumnGroupDefinition columnColumnGroup = ColumnColumnGroupDefinitionLocalServiceUtil
.createColumnColumnGroupDefinition(IDGenerator.increment(ColumnColumnGroupDefinition.class.getName()));
columnColumnGroup.setColumnDefinitionId(columnId);
columnColumnGroup.setColumnGroupDefinitionId(columnGroupContact.getColumnGroupDefinitionId());
ColumnColumnGroupDefinitionLocalServiceUtil.updateColumnColumnGroupDefinition(columnColumnGroup);
}
}
} private static Log _log = LogFactoryUtil.getLog(InitializingDefaultColumn.class); }

5:在Operator-Portlet这个项目中写Portlet对应的增删改查,不要忘记了还要做国际化(content文件中写国际化文件)。

6:写对应的界面。

工作记录之开发HRM项目总结的更多相关文章

  1. 分享vs低版本开发的项目到VS高版本时遇到的4个小问题解决之记录

    分享vs低版本开发的项目到VS高版本时遇到的4个小问题解决之记录 原文首发: http://anforen.com/wp/2017/08/extensionattribute_compilerserv ...

  2. 结合实体框架(代码优先)、工作单元测试、Web API、ASP. net等,以存储库设计模式开发示例项目。NET MVC 5和引导

    介绍 这篇文章将帮助你理解在库模式.实体框架.Web API.SQL Server 2012.ASP中的工作单元测试的帮助下设计一个项目.净MVC应用程序.我们正在开发一个图书实体和作者专用的样例图书 ...

  3. [笔记]记录原开发工作在base命名空间下扩展的属性与方法

    前言 该笔记只是为了记录以前开发使用的方式. 处理命名空间namespace /** * 处理命名空间 * @param {string} 空间名称,可多个 * @return {object} 对象 ...

  4. C语言可以开发哪些项目?

    C语言是我们大多数人的编程入门语言,对其也再熟悉不过了,不过很多初学者在学习的过程中难免会出现迷茫,比如:不知道C语言可以开发哪些项目,可以应用在哪些实际的开发中--,这些迷茫也导致了我们在学习的过程 ...

  5. 循序渐进开发WinForm项目(4)--Winform界面模块的集成使用

    随笔背景:在很多时候,很多入门不久的朋友都会问我:我是从其他语言转到C#开发的,有没有一些基础性的资料给我们学习学习呢,你的框架感觉一下太大了,希望有个循序渐进的教程或者视频来学习就好了. 其实也许我 ...

  6. SSM框架开发web项目系列(二) MyBatis真正的力量

    前言 上篇SSM框架环境搭建篇,演示了我们进行web开发必不可少的一些配置和准备工作,如果这方面还有疑问的地方,可以先参考上一篇“SSM框架开发web项目系列(一) 环境搭建篇”.本文主要介绍MyBa ...

  7. 【物联网】 9个顶级开发IoT项目的开源物联网平台(转)

    物联网(IoT)是帮助人工智能(AI)以更好的方式控制和理解事物的未来技术. 我们收集了一些最有名的物联网平台,帮助您以受控方式开发物联网项目. 物联网平台是帮助设置和管理互联网连接设备的组件套件. ...

  8. 9个顶级开发IoT项目的开源物联网平台

    https://blog.csdn.net/shnbiot/article/details/80432017 物联网(IoT)是帮助人工智能(AI)以更好的方式控制和理解事物的未来技术. 我们收集了一 ...

  9. C语言可以开发哪些项目?(转)

    原文地址:https://www.cnblogs.com/shiyanlou/p/6098661.html 知乎:https://www.zhihu.com/question/20564904 C语言 ...

随机推荐

  1. 【spring教程之中的一个】创建一个最简单的spring样例

    1.首先spring的主要思想,就是依赖注入.简单来说.就是不须要手动new对象,而这些对象由spring容器统一进行管理. 2.样例结构 如上图所看到的,採用的是mavenproject. 2.po ...

  2. Effective C++ Item 15 Provide access to raw resources in resource-managing classes

    In last two item, I talk about resource-managing using RAII, now comes to the practical part. Often, ...

  3. swift - 移除界面上的所有元素

    下面代码可以遍历移除页面视图上的所有元件: //清空所有子视图 func clearViews() { for v in self.view.subviews as [UIView] { v.remo ...

  4. RIDE指定log和report的输出目录

    在命令行中,输入 pybot --help就可以看到他支持的所以命令和相关的介绍 我们可以看到outputdir这个命令,就是来知道report和log的输出目录的 如果你是在命令行中,那么直接后面跟 ...

  5. Gson、FastJson、json-lib对比与实例

    一.各个JSON技术的对比(本部分摘抄自http://www.cnblogs.com/kunpengit/p/4001680.html): 1.json-libjson-lib最开始的也是应用最广泛的 ...

  6. /etc/hostname

    我们可以使用 hostname 命令来修改主机名,但只是临时生效,如果想永久生效可以编辑 /etc/hostname 文件,注意不是每个 Linux 发行版都有该文件 root@Ubuntu_Lee: ...

  7. 说说FATFS文件系统(转)

    FATFS是一个为小型嵌入式系统设计的通用FAT(File Allocation Table)文件系统模块.FatFs 的编写遵循ANSI C,并且完全与磁盘I/O层分开.因此,它独立(不依赖)于硬件 ...

  8. 学习C#基础知识这段时间

    似乎穿越的感觉,我又来到了这周的周五,总是在周五,知道了时间的概念,上午会讲课,但是在下午就是一个总结小练习,上午老师给我们讲了委托,在听课时间感觉很简单啊,哪里有难的地方啊,一直在好奇,老师在演示给 ...

  9. [020]Sencha Ext JS 6.0使用教程2

    本节主要以典型例子介绍如何用Sencha Ext JS6.0进行项目开发 入门阶段总是比较难的,掌握了基本操作步骤,使用方法,架构思维,开发起来还是满顺利,开心的,自己又能掌握一门新技术,又能进步,主 ...

  10. filter IE滤镜(Internet Explorer)CSS

    收集一些IE滤镜,留作之后开发用. 透明度 #myElement { opacity: .; /* other browsers */ filter: progid: DXImageTransform ...