📄 boundformsoperationshelper.java
字号:
List<String> list = new LinkedList<String>();
List<ExternalSet> externalSets = focusManager.getUnmodifiableExternalSet(formName);
if(externalSets != null) {
for (ExternalSet externalForm : externalSets) {
list.add(externalForm.getName());
}
} else {
logger.WARN("Referenced form [" + formName + "], doesn't exists, or cannot be found. ");
}
return list;
}
/**
* Retrieve all information about external fields for the given form #formName.
* @param formName form to be processed
* @param focusManager focus manager
* @param ls logon session
* @param ctx servlet contectx
* @return list of the {@link ExternalFieldStructure} elements
* @throws CouldntGetEJBException thrown if ejb could not be got
* @throws IncorrectEntityDescriptionException thrown if incorrect entity description is found
*/
private static List<ExternalFieldStructure> getBoundByExternalFields(String formName, FocusConfigManagerLocal focusManager,
LogonSession ls, ActionContext ctx)
throws CouldntGetEJBException, IncorrectEntityDescriptionException {
List<ExternalFieldStructure> list = new LinkedList<ExternalFieldStructure>();
List<ExternalField> externalFields = focusManager.getUnmodifiableExternalFields(formName);
if (externalFields != null) {
//iterate it
for (ExternalField externalField : externalFields) {
//retrieve entity name, where this external field is referencing
String entityName = EntityOperationsHelper.getEntityNameFromFormID(externalField.getForm());
//retrieve metadata for this entity
Map<String, FieldMeta> meta = EntityViewHelper.getMetaForEntity(entityName, EntityViewHelper.FieldsModificator.FORM, false, ls, ctx);
//retrieve entity name, that is shown in efield as referencing entity.
String referencedEntityName = EntityViewHelper.getListRefEntityName(entityName, externalField.getName(), ctx);
if (referencedEntityName == null) {//incorrect entity description
throw new IncorrectEntityDescriptionException(entityName, "There is no such field ["
+ externalField.getName() + "] defined in entity [" + entityName + "].");
} else {//fill up structure element
//get list field name for the referenced entity
String listrefFieldName = EntityViewHelper.getListFieldNameForEntity(referencedEntityName, ctx);
//field meta for external field in external form.
FieldMeta fieldMeta = meta.get(externalField.getName());
String sourceField = externalField.getSourceField();
if(StringHelper.isEmpty(sourceField)) {
String thisEntityName = EntityOperationsHelper.
getEntityNameFromFormID(formName);
sourceField = EntityViewHelper.getPkeyID(thisEntityName,
ctx);
}
if (fieldMeta != null) {
ExternalFieldStructure structure
= new ExternalFieldStructure(
externalField.getForm(),
externalField.getName(), fieldMeta,
referencedEntityName, listrefFieldName,
sourceField);
list.add(structure);
} else {
logger.ERROR("Field [" + externalField.getName() + "], wasn't found in entity ["
+ entityName +
"], external field property won't be included to resultset. ");
}
}
}
} else {
logger.WARN("Referenced form [" + formName + "], doesn't exists, or cannot be found. ");
}
return list;
}
public static class ResultFormStructure {
/**
* external sets data
*/
private List<EntityData> entityDatas;
/**
* external fields data
*/
private List<EntityData> fieldDatas;
/**
* grid data objects
*/
private List<GridData> gridData;
public ResultFormStructure(List<EntityData> entityDatas, List<EntityData> fieldDatas, List<GridData> gridData) {
if (entityDatas != null) {
this.entityDatas = entityDatas;
} else {
this.entityDatas = new LinkedList<EntityData>();
}
if (fieldDatas != null) {
this.fieldDatas = fieldDatas;
} else {
this.fieldDatas = new LinkedList<EntityData>();
}
if(gridData != null) {
this.gridData = gridData;
} else {
this.gridData = new ArrayList<GridData>();//will be transferred to GWT hence should be ArrayList, not LinkedList
}
}
public ResultFormStructure() {
this(null, null, null);
}
public List<EntityData> getEntityDatas() {
return entityDatas;
}
public List<EntityData> getFieldDatas() {
return fieldDatas;
}
public List<GridData> getGridData() {
return gridData;
}
public void addEntityData(EntityData data) {
entityDatas.add(data);
}
public void addFieldData(EntityData data) {
fieldDatas.add(data);
}
public void addGridData(GridData data) {
gridData.add(data);
}
}
private static class ExternalFieldStructure {
/**
* external form name
*/
public String formName;
/**
* field name in external form
*/
public String fieldName;
/**
* field meta in external form
*/
public FieldMeta fieldMeta;
/**
* The field, that is shown as external-field actually can be one of the
* following: EntityReference, ListBox. All such fields should have
* <listref entity="users.security"/> value. "users.security" is this
* value here.
*/
public String referencedEntityName;
/**
* @see #referencedEntityName descr. #listrefFieldName is the field
* that is shown as listref="field_name"
*/
public String listrefFieldName;
/**
* Field name from where we should get pkey. By default it's pkey.
*/
public String sourceFieldName;
public ExternalFieldStructure(String formName, String fieldName,
FieldMeta fieldMeta,
String referencedEntityName,
String listrefFieldName,
String sourceFieldName) {
this.formName = formName;
this.fieldName = fieldName;
this.fieldMeta = fieldMeta;
this.referencedEntityName = referencedEntityName;
this.listrefFieldName = listrefFieldName;
this.sourceFieldName = sourceFieldName;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -