private void execute4Instance()
        throws EFapsException
    {
        final Set<String> altOIDSel = new HashSet<>();
        final Form form = getForm();
        // evaluate the Form to make the query
        final PrintQuery print = new PrintQuery(getInstance());
        for (final Field field : form.getFields()) {
            if (field.hasAccess(getMode(), getInstance(), this.getCommand(), getInstance())
                            && !field.isNoneDisplay(getMode())) {
                if (field.getSelect() != null) {
                    print.addSelect(field.getSelect());
                } else if (field.getAttribute() != null) {
                    print.addAttribute(field.getAttribute());
                } else if (field.getPhrase() != null) {
                    print.addPhrase(field.getName(), field.getPhrase());
                }  else if (field.getMsgPhrase() != null) {
                    print.addMsgPhrase(new SelectBuilder(getBaseSelect4MsgPhrase(field)), field.getMsgPhrase());
                }
                if (field.getSelectAlternateOID() != null) {
                    print.addSelect(field.getSelectAlternateOID());
                    altOIDSel.add(field.getSelectAlternateOID());
                }
            }
        }
        if (print.execute()) {
            if (!altOIDSel.isEmpty()) {
                final List<Instance> inst = new ArrayList<>();
                for (final String sel : altOIDSel) {
                    inst.addAll(print.getInstances4Select(sel));
                }
                checkAccessToInstances(inst);
            }
            FormElement currentFormElement = null;
            boolean addNew = true;
            UIClassification uiclass = null;
            boolean firstTable = true;
            for (final Field field : form.getFields()) {
                final Instance instance = evaluateFieldInstance(print, field);
                if (field.hasAccess(getMode(), instance, this.getCommand(), getInstance())
                                && !field.isNoneDisplay(getMode())) {
                    if (field instanceof FieldGroup) {
                        final FieldGroup group = (FieldGroup) field;
                        // in case that the first field is a group the element
                        // must be initiated
                        if (currentFormElement == null) {
                            currentFormElement = new FormElement();
                            this.elements.add(new Element(UIForm.ElementType.FORM, currentFormElement));
                            addNew = false;
                        }
                        currentFormElement.setGroupCount(group.getGroupCount());
                    } else if (field instanceof FieldTable) {
                        if (((FieldTable) field).getTargetStructurBrowserField() == null) {
                            if (isViewMode() && "GridX".equals(Configuration.getAttribute(
                                            ConfigAttribute.TABLE_DEFAULTTYPEFORM))) {
                                final UIFieldGrid grid = UIFieldGrid.get(getCommandUUID(), getPagePosition(),
                                                getInstance(), (FieldTable) field);
                                this.elements.add(new Element(UIForm.ElementType.GRID, grid));
                            } else {
                                final UIFieldTable uiFieldTable = new UIFieldTable(getCommandUUID(),
                                                getInstanceKey(), (FieldTable) field);
                                uiFieldTable.setPagePosition(getPagePosition());
                                uiFieldTable.setMode(getMode());
                                this.elements.add(new Element(UIForm.ElementType.TABLE, uiFieldTable));
                                if (firstTable) {
                                    firstTable = false;
                                } else {
                                    uiFieldTable.setFirstTable(false);
                                }
                            }
                        } else {
                            if (isViewMode() && "GridX".equals(Configuration.getAttribute(
                                            ConfigAttribute.STRUCBRWSR_DEFAULTTYPEFORM))) {
                                final UIFieldGrid grid = UIFieldGrid.get(getCommandUUID(), getPagePosition(),
                                                getInstance(), (FieldTable) field);
                                this.elements.add(new Element(UIForm.ElementType.GRID, grid));
                            } else {
                                final UIFieldStructurBrowser uiFieldStrucBrws = new UIFieldStructurBrowser(
                                            getCommandUUID(),
                                            getInstanceKey(), (FieldTable) field);
                                uiFieldStrucBrws.setMode(getMode());
                                this.elements.add(new Element(UIForm.ElementType.STRUCBRWS, uiFieldStrucBrws));
                            }
                        }
                        addNew = true;
                    } else if (field instanceof FieldHeading) {
                        this.elements.add(new Element(UIForm.ElementType.HEADING,
                                        new UIHeading((FieldHeading) field)));
                        addNew = true;
                    } else if (field instanceof FieldClassification) {
                        uiclass = UIClassification.getUIClassification(field, this);
                        this.elements.add(new Element(UIForm.ElementType.CLASSIFICATION, uiclass));
                        addNew = true;
                        this.classified = true;
                    } else {
                        if (addNew) {
                            final FormElement formElement = new FormElement().setGroupCount(currentFormElement == null
                                            ? 0 : currentFormElement.getGroupCount());
                            currentFormElement = formElement;
                            this.elements.add(new Element(UIForm.ElementType.FORM, currentFormElement));
                            addNew = false;
                        }
                        addCell2FormRow(currentFormElement, print, field);
                    }
                }
            }
            if (uiclass != null) {
                final Map<UUID, String> instanceKeys = uiclass.getClassInstanceKeys(getInstance());
                if (instanceKeys.size() > 0) {
                    if (!uiclass.isInitialized()) {
                        uiclass.execute(getInstance());
                    }
                    addClassElements(uiclass, instanceKeys);
                }
            }
        }
    }
private void execute4Instance()
        throws EFapsException
    {
        final Set<String> altOIDSel = new HashSet<>();
        final Form form = getForm();
        
        final PrintQuery print = new PrintQuery(getInstance());
        for (final Field field : form.getFields()) {
            if (field.hasAccess(getMode(), getInstance(), this.getCommand(), getInstance())
                            && !field.isNoneDisplay(getMode())) {
                if (field.getSelect() != null) {
                    print.addSelect(field.getSelect());
                } else if (field.getAttribute() != null) {
                    print.addAttribute(field.getAttribute());
                } else if (field.getPhrase() != null) {
                    print.addPhrase(field.getName(), field.getPhrase());
                }  else if (field.getMsgPhrase() != null) {
                    print.addMsgPhrase(new SelectBuilder(getBaseSelect4MsgPhrase(field)), field.getMsgPhrase());
                }
                if (field.getSelectAlternateOID() != null) {
                    print.addSelect(field.getSelectAlternateOID());
                    altOIDSel.add(field.getSelectAlternateOID());
                }
            }
        }
        if (print.execute()) {
            if (!altOIDSel.isEmpty()) {
                final List<Instance> inst = new ArrayList<>();
                for (final String sel : altOIDSel) {
                    inst.addAll(print.getInstances4Select(sel));
                }
                checkAccessToInstances(inst);
            }
            FormElement currentFormElement = null;
            boolean addNew = true;
            UIClassification uiclass = null;
            boolean firstTable = true;
            for (final Field field : form.getFields()) {
                final Instance instance = evaluateFieldInstance(print, field);
                if (field.hasAccess(getMode(), instance, this.getCommand(), getInstance())
                                && !field.isNoneDisplay(getMode())) {
                    if (field instanceof FieldGroup) {
                        final FieldGroup group = (FieldGroup) field;
                        
                        
                        if (currentFormElement == null) {
                            currentFormElement = new FormElement();
                            this.elements.add(new Element(UIForm.ElementType.FORM, currentFormElement));
                            addNew = false;
                        }
                        currentFormElement.setGroupCount(group.getGroupCount());
                    } else if (field instanceof FieldTable) {
                        if (((FieldTable) field).getTargetStructurBrowserField() == null) {
                            if (isViewMode() && "GridX".equals(Configuration.getAttribute(
                                            ConfigAttribute.TABLE_DEFAULTTYPEFORM))) {
                                final UIFieldGrid grid = UIFieldGrid.get(getCommandUUID(), getPagePosition(),
                                                getInstance(), (FieldTable) field);
                                this.elements.add(new Element(UIForm.ElementType.GRID, grid));
                            } else {
                                final UIFieldTable uiFieldTable = new UIFieldTable(getCommandUUID(),
                                                getInstanceKey(), (FieldTable) field);
                                uiFieldTable.setPagePosition(getPagePosition());
                                uiFieldTable.setMode(getMode());
                                this.elements.add(new Element(UIForm.ElementType.TABLE, uiFieldTable));
                                if (firstTable) {
                                    firstTable = false;
                                } else {
                                    uiFieldTable.setFirstTable(false);
                                }
                            }
                        } else {
                            if (isViewMode() && "GridX".equals(Configuration.getAttribute(
                                            ConfigAttribute.STRUCBRWSR_DEFAULTTYPEFORM))) {
                                final UIFieldGrid grid = UIFieldGrid.get(getCommandUUID(), getPagePosition(),
                                                getInstance(), (FieldTable) field);
                                this.elements.add(new Element(UIForm.ElementType.GRID, grid));
                            } else {
                                final UIFieldStructurBrowser uiFieldStrucBrws = new UIFieldStructurBrowser(
                                            getCommandUUID(),
                                            getInstanceKey(), (FieldTable) field);
                                uiFieldStrucBrws.setMode(getMode());
                                this.elements.add(new Element(UIForm.ElementType.STRUCBRWS, uiFieldStrucBrws));
                            }
                        }
                        addNew = true;
                    } else if (field instanceof FieldHeading) {
                        this.elements.add(new Element(UIForm.ElementType.HEADING,
                                        new UIHeading((FieldHeading) field)));
                        addNew = true;
                    } else if (field instanceof FieldClassification) {
                        uiclass = UIClassification.getUIClassification(field, this);
                        this.elements.add(new Element(UIForm.ElementType.CLASSIFICATION, uiclass));
                        addNew = true;
                        this.classified = true;
                    } else {
                        if (addNew) {
                            final FormElement formElement = new FormElement().setGroupCount(currentFormElement == null
                                            ? 0 : currentFormElement.getGroupCount());
                            currentFormElement = formElement;
                            this.elements.add(new Element(UIForm.ElementType.FORM, currentFormElement));
                            addNew = false;
                        }
                        addCell2FormRow(currentFormElement, print, field);
                    }
                }
            }
            if (uiclass != null) {
                final Map<UUID, String> instanceKeys = uiclass.getClassInstanceKeys(getInstance());
                if (instanceKeys.size() > 0) {
                    if (!uiclass.isInitialized()) {
                        uiclass.execute(getInstance());
                    }
                    addClassElements(uiclass, instanceKeys);
                }
            }
        }
    }
private void execute4Instance ( ) throws EFapsException { final Set < String > altOIDSel = new HashSet <> ( ) ; final Form form = getForm ( ) ; // evaluate the Form to make the query final PrintQuery print = new PrintQuery ( getInstance ( ) ) ; for ( final Field field : form . getFields ( ) ) { if ( field . hasAccess ( getMode ( ) , getInstance ( ) , this . getCommand ( ) , getInstance ( ) ) && ! field . isNoneDisplay ( getMode ( ) ) ) { if ( field . getSelect ( ) != null ) { print . addSelect ( field . getSelect ( ) ) ; } else if ( field . getAttribute ( ) != null ) { print . addAttribute ( field . getAttribute ( ) ) ; } else if ( field . getPhrase ( ) != null ) { print . addPhrase ( field . getName ( ) , field . getPhrase ( ) ) ; } else if ( field . getMsgPhrase ( ) != null ) { print . addMsgPhrase ( new SelectBuilder ( getBaseSelect4MsgPhrase ( field ) ) , field . getMsgPhrase ( ) ) ; } if ( field . getSelectAlternateOID ( ) != null ) { print . addSelect ( field . getSelectAlternateOID ( ) ) ; altOIDSel . add ( field . getSelectAlternateOID ( ) ) ; } } } if ( print . execute ( ) ) { if ( ! altOIDSel . isEmpty ( ) ) { final List < Instance > inst = new ArrayList <> ( ) ; for ( final String sel : altOIDSel ) { inst . addAll ( print . getInstances4Select ( sel ) ) ; } checkAccessToInstances ( inst ) ; } FormElement currentFormElement = null ; boolean addNew = true ; UIClassification uiclass = null ; boolean firstTable = true ; for ( final Field field : form . getFields ( ) ) { final Instance instance = evaluateFieldInstance ( print , field ) ; if ( field . hasAccess ( getMode ( ) , instance , this . getCommand ( ) , getInstance ( ) ) && ! field . isNoneDisplay ( getMode ( ) ) ) { if ( field instanceof FieldGroup ) { final FieldGroup group = ( FieldGroup ) field ; // in case that the first field is a group the element // must be initiated if ( currentFormElement == null ) { currentFormElement = new FormElement ( ) ; this . elements . add ( new Element ( UIForm . ElementType . FORM , currentFormElement ) ) ; addNew = false ; } currentFormElement . setGroupCount ( group . getGroupCount ( ) ) ; } else if ( field instanceof FieldTable ) { if ( ( ( FieldTable ) field ) . getTargetStructurBrowserField ( ) == null ) { if ( isViewMode ( ) && "GridX" . equals ( Configuration . getAttribute ( ConfigAttribute . TABLE_DEFAULTTYPEFORM ) ) ) { final UIFieldGrid grid = UIFieldGrid . get ( getCommandUUID ( ) , getPagePosition ( ) , getInstance ( ) , ( FieldTable ) field ) ; this . elements . add ( new Element ( UIForm . ElementType . GRID , grid ) ) ; } else { final UIFieldTable uiFieldTable = new UIFieldTable ( getCommandUUID ( ) , getInstanceKey ( ) , ( FieldTable ) field ) ; uiFieldTable . setPagePosition ( getPagePosition ( ) ) ; uiFieldTable . setMode ( getMode ( ) ) ; this . elements . add ( new Element ( UIForm . ElementType . TABLE , uiFieldTable ) ) ; if ( firstTable ) { firstTable = false ; } else { uiFieldTable . setFirstTable ( false ) ; } } } else { if ( isViewMode ( ) && "GridX" . equals ( Configuration . getAttribute ( ConfigAttribute . STRUCBRWSR_DEFAULTTYPEFORM ) ) ) { final UIFieldGrid grid = UIFieldGrid . get ( getCommandUUID ( ) , getPagePosition ( ) , getInstance ( ) , ( FieldTable ) field ) ; this . elements . add ( new Element ( UIForm . ElementType . GRID , grid ) ) ; } else { final UIFieldStructurBrowser uiFieldStrucBrws = new UIFieldStructurBrowser ( getCommandUUID ( ) , getInstanceKey ( ) , ( FieldTable ) field ) ; uiFieldStrucBrws . setMode ( getMode ( ) ) ; this . elements . add ( new Element ( UIForm . ElementType . STRUCBRWS , uiFieldStrucBrws ) ) ; } } addNew = true ; } else if ( field instanceof FieldHeading ) { this . elements . add ( new Element ( UIForm . ElementType . HEADING , new UIHeading ( ( FieldHeading ) field ) ) ) ; addNew = true ; } else if ( field instanceof FieldClassification ) { uiclass = UIClassification . getUIClassification ( field , this ) ; this . elements . add ( new Element ( UIForm . ElementType . CLASSIFICATION , uiclass ) ) ; addNew = true ; this . classified = true ; } else { if ( addNew ) { final FormElement formElement = new FormElement ( ) . setGroupCount ( currentFormElement == null ? 0 : currentFormElement . getGroupCount ( ) ) ; currentFormElement = formElement ; this . elements . add ( new Element ( UIForm . ElementType . FORM , currentFormElement ) ) ; addNew = false ; } addCell2FormRow ( currentFormElement , print , field ) ; } } } if ( uiclass != null ) { final Map < UUID , String > instanceKeys = uiclass . getClassInstanceKeys ( getInstance ( ) ) ; if ( instanceKeys . size ( ) > 0 ) { if ( ! uiclass . isInitialized ( ) ) { uiclass . execute ( getInstance ( ) ) ; } addClassElements ( uiclass , instanceKeys ) ; } } } }
Method to execute the form in case that a instance is existing.

@throws EFapsException

@throws EFapsException on error
Method to execute the form in case that a instance is existing .