📄 uiscreeneventprocessor.java
字号:
/*
*
* Copyright (c) 2004 SourceTap - www.sourcetap.com
*
* The contents of this file are subject to the SourceTap Public License
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
*/
package com.sourcetap.sfa.customization;
import com.sourcetap.sfa.event.GenericEventProcessor;
import org.ofbiz.entity.*;
import org.ofbiz.entity.model.ModelEntity;
import java.util.*;
/**
* DOCUMENT ME!
*
*/
public class UIScreenEventProcessor extends GenericEventProcessor {
private static final boolean DEBUG = false;
// Define function to get all entities (screen section entities) associated with a section.
protected Iterator getUiScreenSectionEntityIterator(String sectionId,
GenericDelegator delegator) throws GenericEntityException {
HashMap uiScreenSectionEntityMap = new HashMap();
uiScreenSectionEntityMap.put("sectionId", sectionId);
ArrayList order = new ArrayList();
order.add("entityId");
List uiScreenSectionEntitys = delegator.findByAnd("UiScreenSectionEntity",
uiScreenSectionEntityMap, order);
return uiScreenSectionEntitys.iterator();
}
// Define function to get all attributes (screen section infos) associated with a section.
protected Iterator getUiScreenSectionInfoIterator(String sectionId,
GenericDelegator delegator) throws GenericEntityException {
HashMap uiScreenSectionInfoMap = new HashMap();
uiScreenSectionInfoMap.put("sectionId", sectionId);
ArrayList order = new ArrayList();
order.add("partyId");
order.add("displayOrder");
List uiScreenSectionInfos = delegator.findByAnd("UiScreenSectionInfo",
uiScreenSectionInfoMap, order);
return uiScreenSectionInfos.iterator();
}
// Define function to add missing eligible attributes.
public void addMissingAttributes(String sectionId,
GenericDelegator delegator, String partyId)
throws GenericEntityException {
ModelEntity uiScreenSectionInfoEntity = delegator.getModelEntity(
"UiScreenSectionInfo");
// Get the entities associated with this screen section.
Iterator uiScreenSectionEntityIterator2 = getUiScreenSectionEntityIterator(sectionId,
delegator);
// Loop through entities associated with this screen section.
while (uiScreenSectionEntityIterator2.hasNext()) {
GenericValue uiScreenSectionEntityDetails = (GenericValue) uiScreenSectionEntityIterator2.next();
// Get the attributes associated with this entity.
HashMap uiAttributeMap = new HashMap();
uiAttributeMap.put("entityId",
uiScreenSectionEntityDetails.getString("entityId"));
List uiAttributes = delegator.findByAnd("UiAttribute",
uiAttributeMap, null);
Iterator uiAttributeIterator2 = uiAttributes.iterator();
// Loop through all eligible attributes for this entity.
while (uiAttributeIterator2.hasNext()) {
GenericValue uiAttributeDetails = (GenericValue) uiAttributeIterator2.next();
boolean attributeFound = false;
// Get the attributes associated with this screen section.
Iterator uiScreenSectionInfoIterator2 = getUiScreenSectionInfoIterator(sectionId,
delegator);
// Loop through the already associated attributes to see if this on is already associated with the section
// for the specified party ID.
while (uiScreenSectionInfoIterator2.hasNext()) {
GenericValue uiScreenSectionInfoDetails = (GenericValue) uiScreenSectionInfoIterator2.next();
// See if this is a match.
if (uiScreenSectionInfoDetails.getString("attributeId")
.equals(uiAttributeDetails.getString(
"attributeId")) &&
uiScreenSectionInfoDetails.getString("partyId")
.equals(partyId)) {
// This is a match. We don't need to add this one.
attributeFound = true;
}
}
// Clear the screen section info iterator so we can loop through it again.
uiScreenSectionInfoIterator2 = null;
if (!attributeFound) {
// This eligible attribute is not associated with the screen section for this party ID. Add it.
GenericValue newUiScreenSectionInfoDetails = new GenericValue(uiScreenSectionInfoEntity);
newUiScreenSectionInfoDetails.setDelegator(delegator);
newUiScreenSectionInfoDetails.set("sectionId", sectionId);
newUiScreenSectionInfoDetails.set("partyId", partyId);
newUiScreenSectionInfoDetails.set("displayObjectId",
uiAttributeDetails.getString("displayObjectId"));
newUiScreenSectionInfoDetails.set("attributeId",
uiAttributeDetails.getString("attributeId"));
newUiScreenSectionInfoDetails.set("maxLength",
uiAttributeDetails.getString("maxLength"));
newUiScreenSectionInfoDetails.set("isMandatory",
uiAttributeDetails.getString("isMandatory"));
newUiScreenSectionInfoDetails.set("isReadOnly",
uiAttributeDetails.getString("isReadOnly"));
newUiScreenSectionInfoDetails.set("isVisible",
uiAttributeDetails.getString("isVisible"));
newUiScreenSectionInfoDetails.set("isSearchable",
uiAttributeDetails.getString("isSearchable"));
newUiScreenSectionInfoDetails.set("displayOrder",
uiAttributeDetails.getString("displayOrder"));
newUiScreenSectionInfoDetails.set("displayLabel",
uiAttributeDetails.getString("displayLabel"));
newUiScreenSectionInfoDetails.set("displayLength",
uiAttributeDetails.getString("displayLength"));
newUiScreenSectionInfoDetails.set("rowSpan",
uiAttributeDetails.getString("rowSpan"));
newUiScreenSectionInfoDetails.set("colSpan",
uiAttributeDetails.getString("colSpan"));
delegator.create(newUiScreenSectionInfoDetails);
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -