Search in sources :

Example 1 with AutoFieldsEntity

use of org.apache.ofbiz.widget.model.ModelForm.AutoFieldsEntity 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

GeneralException (org.apache.ofbiz.base.util.GeneralException)1 FieldInfo (org.apache.ofbiz.widget.model.FieldInfo)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 ModelFormField (org.apache.ofbiz.widget.model.ModelFormField)1 DisplayEntityField (org.apache.ofbiz.widget.model.ModelFormField.DisplayEntityField)1 FieldInfoWithOptions (org.apache.ofbiz.widget.model.ModelFormField.FieldInfoWithOptions)1