Search in sources :

Example 6 with FieldInfo

use of org.apache.ofbiz.widget.model.FieldInfo in project ofbiz-framework by apache.

the class ArtifactInfoGatherer method visitModelForm.

public void visitModelForm(ModelForm modelForm) throws Exception {
    if (modelForm.getActions() != null) {
        for (ModelAction action : modelForm.getActions()) {
            action.accept(this);
        }
    }
    if (modelForm.getRowActions() != null) {
        for (ModelAction action : modelForm.getRowActions()) {
            action.accept(this);
        }
    }
    for (AutoFieldsEntity autoFieldsEntity : modelForm.getAutoFieldsEntities()) {
        infoContext.addEntityName(autoFieldsEntity.entityName);
    }
    for (AutoFieldsService autoFieldsService : modelForm.getAutoFieldsServices()) {
        infoContext.addServiceName(autoFieldsService.serviceName);
    }
    if (modelForm.getAltTargets() != null) {
        for (AltTarget altTarget : modelForm.getAltTargets()) {
            String target = altTarget.targetExdr.getOriginal();
            String urlMode = "intra-app";
            try {
                Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target, urlMode);
                if (controllerLocAndRequestSet != null) {
                    for (String requestLocation : controllerLocAndRequestSet) {
                        infoContext.addTargetLocation(requestLocation);
                    }
                }
            } catch (GeneralException e) {
                throw new RuntimeException(e);
            }
        }
    }
    if (!modelForm.getTarget().isEmpty()) {
        String target = modelForm.getTarget();
        String urlMode = UtilValidate.isNotEmpty(modelForm.getTargetType()) ? modelForm.getTargetType() : "intra-app";
        if (target.indexOf("${") < 0) {
            try {
                Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target, urlMode);
                if (controllerLocAndRequestSet != null) {
                    for (String requestLocation : controllerLocAndRequestSet) {
                        infoContext.addTargetLocation(requestLocation);
                    }
                }
            } catch (GeneralException e) {
                throw new RuntimeException(e);
            }
        }
    }
    FieldInfoGatherer fieldInfoGatherer = new FieldInfoGatherer();
    for (ModelFormField modelFormField : modelForm.getFieldList()) {
        if (UtilValidate.isNotEmpty(modelFormField.getEntityName())) {
            infoContext.addEntityName(modelFormField.getEntityName());
        }
        if (modelFormField.getFieldInfo() instanceof ModelFormField.DisplayEntityField) {
            infoContext.addEntityName(((ModelFormField.DisplayEntityField) modelFormField.getFieldInfo()).getEntityName());
        }
        if (modelFormField.getFieldInfo() instanceof FieldInfoWithOptions) {
            for (ModelFormField.OptionSource optionSource : ((FieldInfoWithOptions) modelFormField.getFieldInfo()).getOptionSources()) {
                if (optionSource instanceof ModelFormField.EntityOptions) {
                    infoContext.addEntityName(((ModelFormField.EntityOptions) optionSource).getEntityName());
                }
            }
        }
        if (UtilValidate.isNotEmpty(modelFormField.getServiceName())) {
            infoContext.addServiceName(modelFormField.getServiceName());
        }
        FieldInfo fieldInfo = modelFormField.getFieldInfo();
        if (fieldInfo != null) {
            fieldInfo.accept(fieldInfoGatherer);
        }
    }
}
Also used : GeneralException(org.apache.ofbiz.base.util.GeneralException) AutoFieldsService(org.apache.ofbiz.widget.model.ModelForm.AutoFieldsService) ModelFormField(org.apache.ofbiz.widget.model.ModelFormField) AltTarget(org.apache.ofbiz.widget.model.ModelForm.AltTarget) FieldInfoWithOptions(org.apache.ofbiz.widget.model.ModelFormField.FieldInfoWithOptions) AutoFieldsEntity(org.apache.ofbiz.widget.model.ModelForm.AutoFieldsEntity) ModelAction(org.apache.ofbiz.widget.model.ModelAction) DisplayEntityField(org.apache.ofbiz.widget.model.ModelFormField.DisplayEntityField) FieldInfo(org.apache.ofbiz.widget.model.FieldInfo)

Aggregations

FieldInfo (org.apache.ofbiz.widget.model.FieldInfo)6 ModelFormField (org.apache.ofbiz.widget.model.ModelFormField)6 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Iterator (java.util.Iterator)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 TreeSet (java.util.TreeSet)1 GeneralException (org.apache.ofbiz.base.util.GeneralException)1 GenericEntity (org.apache.ofbiz.entity.GenericEntity)1 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)1 EntityListIterator (org.apache.ofbiz.entity.util.EntityListIterator)1 ModelAction (org.apache.ofbiz.widget.model.ModelAction)1 AltTarget (org.apache.ofbiz.widget.model.ModelForm.AltTarget)1 AutoFieldsEntity (org.apache.ofbiz.widget.model.ModelForm.AutoFieldsEntity)1 AutoFieldsService (org.apache.ofbiz.widget.model.ModelForm.AutoFieldsService)1 FieldGroup (org.apache.ofbiz.widget.model.ModelForm.FieldGroup)1 FieldGroupBase (org.apache.ofbiz.widget.model.ModelForm.FieldGroupBase)1