em.remove(ieProfileDetail);
}
int seqNum = 0;
for (IeProfileDetailDisplayForm detailForm : form.getIeProfileGeneralDetails()) {
IeProfileDetail ieProfileDetail = new IeProfileDetail();
ieProfileDetail.setIeProfileGroupName(detailForm.getIeProfileGroupName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileGroupIndex())) {
ieProfileDetail.setIeProfileGroupIndex(Integer.valueOf(detailForm.getIeProfileGroupIndex()));
}
ieProfileDetail.setIeProfileFieldName(detailForm.getIeProfileFieldName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileFieldValue())) {
ieProfileDetail.setIeProfileFieldValue(detailForm.getIeProfileFieldValue());
}
ieProfileDetail.setSeqNum(Integer.valueOf(seqNum++));
if (!Format.isNullOrEmpty(detailForm.getIeProfilePosition())) {
ieProfileDetail.setIeProfilePosition(Integer.valueOf(detailForm.getIeProfilePosition()));
}
ieProfileDetail.setRecUpdateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
ieProfileDetail.setRecCreateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecCreateDatetime(new Date(System.currentTimeMillis()));
em.persist(ieProfileDetail);
ieProfileDetail.setIeProfileHeader(ieProfileHeader);
}
int groupIndex = -1;
for (IeProfileDetailDisplayForm detailForm : form.getIeProfileCategoryDetails()) {
if (detailForm.getIeProfileFieldName().equals("catId")) {
groupIndex++;
}
IeProfileDetail ieProfileDetail = new IeProfileDetail();
ieProfileDetail.setIeProfileGroupName(detailForm.getIeProfileGroupName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileGroupIndex())) {
ieProfileDetail.setIeProfileGroupIndex(groupIndex);
}
ieProfileDetail.setIeProfileFieldName(detailForm.getIeProfileFieldName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileFieldValue())) {
ieProfileDetail.setIeProfileFieldValue(detailForm.getIeProfileFieldValue());
}
ieProfileDetail.setSeqNum(Integer.valueOf(seqNum++));
if (!Format.isNullOrEmpty(detailForm.getIeProfilePosition())) {
ieProfileDetail.setIeProfilePosition(Integer.valueOf(detailForm.getIeProfilePosition()));
}
ieProfileDetail.setRecUpdateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
ieProfileDetail.setRecCreateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecCreateDatetime(new Date(System.currentTimeMillis()));
em.persist(ieProfileDetail);
ieProfileDetail.setIeProfileHeader(ieProfileHeader);
}
groupIndex = -1;
for (IeProfileDetailDisplayForm detailForm : form.getIeProfileItemRelatedDetails()) {
if (detailForm.getIeProfileFieldName().equals("itemId")) {
groupIndex++;
}
IeProfileDetail ieProfileDetail = new IeProfileDetail();
ieProfileDetail.setIeProfileGroupName(detailForm.getIeProfileGroupName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileGroupIndex())) {
ieProfileDetail.setIeProfileGroupIndex(groupIndex);
}
ieProfileDetail.setIeProfileFieldName(detailForm.getIeProfileFieldName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileFieldValue())) {
ieProfileDetail.setIeProfileFieldValue(detailForm.getIeProfileFieldValue());
}
ieProfileDetail.setSeqNum(Integer.valueOf(seqNum++));
if (!Format.isNullOrEmpty(detailForm.getIeProfilePosition())) {
ieProfileDetail.setIeProfilePosition(Integer.valueOf(detailForm.getIeProfilePosition()));
}
ieProfileDetail.setRecUpdateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
ieProfileDetail.setRecCreateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecCreateDatetime(new Date(System.currentTimeMillis()));
em.persist(ieProfileDetail);
ieProfileDetail.setIeProfileHeader(ieProfileHeader);
}
groupIndex = -1;
for (IeProfileDetailDisplayForm detailForm : form.getIeProfileItemUpSellDetails()) {
if (detailForm.getIeProfileFieldName().equals("itemId")) {
groupIndex++;
}
IeProfileDetail ieProfileDetail = new IeProfileDetail();
ieProfileDetail.setIeProfileGroupName(detailForm.getIeProfileGroupName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileGroupIndex())) {
ieProfileDetail.setIeProfileGroupIndex(groupIndex);
}
ieProfileDetail.setIeProfileFieldName(detailForm.getIeProfileFieldName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileFieldValue())) {
ieProfileDetail.setIeProfileFieldValue(detailForm.getIeProfileFieldValue());
}
ieProfileDetail.setSeqNum(Integer.valueOf(seqNum++));
if (!Format.isNullOrEmpty(detailForm.getIeProfilePosition())) {
ieProfileDetail.setIeProfilePosition(Integer.valueOf(detailForm.getIeProfilePosition()));
}
ieProfileDetail.setRecUpdateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
ieProfileDetail.setRecCreateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecCreateDatetime(new Date(System.currentTimeMillis()));
em.persist(ieProfileDetail);
ieProfileDetail.setIeProfileHeader(ieProfileHeader);
}
groupIndex = -1;
for (IeProfileDetailDisplayForm detailForm : form.getIeProfileItemCrossSellDetails()) {
if (detailForm.getIeProfileFieldName().equals("itemId")) {
groupIndex++;
}
IeProfileDetail ieProfileDetail = new IeProfileDetail();
ieProfileDetail.setIeProfileGroupName(detailForm.getIeProfileGroupName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileGroupIndex())) {
ieProfileDetail.setIeProfileGroupIndex(groupIndex);
}
ieProfileDetail.setIeProfileFieldName(detailForm.getIeProfileFieldName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileFieldValue())) {
ieProfileDetail.setIeProfileFieldValue(detailForm.getIeProfileFieldValue());
}
ieProfileDetail.setSeqNum(Integer.valueOf(seqNum++));
if (!Format.isNullOrEmpty(detailForm.getIeProfilePosition())) {
ieProfileDetail.setIeProfilePosition(Integer.valueOf(detailForm.getIeProfilePosition()));
}
ieProfileDetail.setRecUpdateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
ieProfileDetail.setRecCreateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecCreateDatetime(new Date(System.currentTimeMillis()));
em.persist(ieProfileDetail);
ieProfileDetail.setIeProfileHeader(ieProfileHeader);
}
groupIndex = -1;
for (IeProfileDetailDisplayForm detailForm : form.getIeProfileItemTierPriceDetails()) {
if (detailForm.getIeProfileFieldName().equals("custClassId")) {
groupIndex++;
}
IeProfileDetail ieProfileDetail = new IeProfileDetail();
ieProfileDetail.setIeProfileGroupName(detailForm.getIeProfileGroupName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileGroupIndex())) {
ieProfileDetail.setIeProfileGroupIndex(groupIndex);
}
ieProfileDetail.setIeProfileFieldName(detailForm.getIeProfileFieldName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileFieldValue())) {
ieProfileDetail.setIeProfileFieldValue(detailForm.getIeProfileFieldValue());
}
ieProfileDetail.setSeqNum(Integer.valueOf(seqNum++));
if (!Format.isNullOrEmpty(detailForm.getIeProfilePosition())) {
ieProfileDetail.setIeProfilePosition(Integer.valueOf(detailForm.getIeProfilePosition()));
}
ieProfileDetail.setRecUpdateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
ieProfileDetail.setRecCreateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecCreateDatetime(new Date(System.currentTimeMillis()));
em.persist(ieProfileDetail);
ieProfileDetail.setIeProfileHeader(ieProfileHeader);
}
groupIndex = -1;
for (IeProfileDetailDisplayForm detailForm : form.getIeProfileItemAttributeDetails()) {
if (detailForm.getIeProfileFieldName().equals("customAttribId")) {
groupIndex++;
}
IeProfileDetail ieProfileDetail = new IeProfileDetail();
ieProfileDetail.setIeProfileGroupName(detailForm.getIeProfileGroupName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileGroupIndex())) {
ieProfileDetail.setIeProfileGroupIndex(groupIndex);
}
ieProfileDetail.setIeProfileFieldName(detailForm.getIeProfileFieldName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileFieldValue())) {
ieProfileDetail.setIeProfileFieldValue(detailForm.getIeProfileFieldValue());
}
ieProfileDetail.setSeqNum(Integer.valueOf(seqNum++));
if (!Format.isNullOrEmpty(detailForm.getIeProfilePosition())) {
ieProfileDetail.setIeProfilePosition(Integer.valueOf(detailForm.getIeProfilePosition()));
}
ieProfileDetail.setRecUpdateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
ieProfileDetail.setRecCreateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecCreateDatetime(new Date(System.currentTimeMillis()));
em.persist(ieProfileDetail);
ieProfileDetail.setIeProfileHeader(ieProfileHeader);
}
groupIndex = -1;
for (IeProfileDetailDisplayForm detailForm : form.getIeProfileItemImageDetails()) {
if (detailForm.getIeProfileFieldName().equals("itemImageLocation")) {
groupIndex++;
}
IeProfileDetail ieProfileDetail = new IeProfileDetail();
ieProfileDetail.setIeProfileGroupName(detailForm.getIeProfileGroupName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileGroupIndex())) {
ieProfileDetail.setIeProfileGroupIndex(groupIndex);
}
ieProfileDetail.setIeProfileFieldName(detailForm.getIeProfileFieldName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileFieldValue())) {
ieProfileDetail.setIeProfileFieldValue(detailForm.getIeProfileFieldValue());
}
ieProfileDetail.setSeqNum(Integer.valueOf(seqNum++));
if (!Format.isNullOrEmpty(detailForm.getIeProfilePosition())) {
ieProfileDetail.setIeProfilePosition(Integer.valueOf(detailForm.getIeProfilePosition()));
}
ieProfileDetail.setRecUpdateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
ieProfileDetail.setRecCreateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecCreateDatetime(new Date(System.currentTimeMillis()));
em.persist(ieProfileDetail);
ieProfileDetail.setIeProfileHeader(ieProfileHeader);
}
groupIndex = -1;
for (IeProfileDetailDisplayForm detailForm : form.getIeProfileOtherDetails()) {
if (detailForm.getIeProfileFieldName().equals("default")) {
groupIndex++;
}
IeProfileDetail ieProfileDetail = new IeProfileDetail();
ieProfileDetail.setIeProfileGroupName(detailForm.getIeProfileGroupName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileGroupIndex())) {
ieProfileDetail.setIeProfileGroupIndex(groupIndex);
}
ieProfileDetail.setIeProfileFieldName(detailForm.getIeProfileFieldName());
if (!Format.isNullOrEmpty(detailForm.getIeProfileFieldValue())) {
ieProfileDetail.setIeProfileFieldValue(detailForm.getIeProfileFieldValue());
}
ieProfileDetail.setSeqNum(Integer.valueOf(seqNum++));
if (!Format.isNullOrEmpty(detailForm.getIeProfilePosition())) {
ieProfileDetail.setIeProfilePosition(Integer.valueOf(detailForm.getIeProfilePosition()));
}
ieProfileDetail.setRecUpdateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
ieProfileDetail.setRecCreateBy(adminBean.getUser().getUserId());
ieProfileDetail.setRecCreateDatetime(new Date(System.currentTimeMillis()));
em.persist(ieProfileDetail);
ieProfileDetail.setIeProfileHeader(ieProfileHeader);
}
form.setIeProfileHeaderId(Format.getLong(ieProfileHeader.getIeProfileHeaderId()));
form.setMode("U");
FormUtils.setFormDisplayMode(request, form, FormUtils.EDIT_MODE);