@Nullable
  public Date getIncorporationDate() {
    if (incorporationDay == null || incorporationMonth == null || incorporationYear == null) {
      return null;
    }

    GregorianCalendar calendarDay = new GregorianCalendar(incorporationYear, incorporationMonth, incorporationDay);
    return calendarDay.getTime();
  }

@ Nullable public Date getIncorporationDate ( ) { if ( incorporationDay == null || incorporationMonth == null || incorporationYear == null ) { return null ; } GregorianCalendar calendarDay = new GregorianCalendar ( incorporationYear , incorporationMonth , incorporationDay ) ; return calendarDay . getTime ( ) ; }

Gets the date of incorporation.

@return the incorporation date


public List<Candidate> getRevisionHistory() {
    List<Candidate> candidates = restAdapter.getCandidateHistory(getId());

    for (Candidate candidate : candidates) {
      candidate.setAdapter(restAdapter);
    }

    return Collections.unmodifiableList(candidates);
  }

public List < Candidate > getRevisionHistory ( ) { List < Candidate > candidates = restAdapter . getCandidateHistory ( getId ( ) ) ; for ( Candidate candidate : candidates ) { candidate . setAdapter ( restAdapter ) ; } return Collections . unmodifiableList ( candidates ) ; }

Returns a complete revision history of a candidate's edits. This allows you to maintain a full
audit trail of when and how you update a client's profile over time. The latest revision is
presented at the top of the list, and the original is at the end of the list.
@return the list of candidates

Returns a complete revision history of a candidate s edits . This allows you to maintain a full audit trail of when and how you update a client s profile over time . The latest revision is presented at the top of the list and the original is at the end of the list .


public PaginatedResult<WatchlistHit> searchWatchlists(EntityType entityType, Double similarityThreshold) {
    Map<String, String> queryOptions = new HashMap<String, String>();
    queryOptions.put("candidate_id", getId());

    if (entityType != null) {
      queryOptions.put("match_type", String.valueOf(entityType));
    }

    if (similarityThreshold != null) {
      queryOptions.put("similarity_threshold", String.valueOf(similarityThreshold));
    }

    WatchlistSearchResults results = restAdapter.searchWatchlists(queryOptions);

    //wrap the result's data with PaginatedResult to make v5.0 transition simpler
    return new PaginatedResult<WatchlistHit>(results.getMatches(), results.getCount(), false);
  }

Performs a watchlist search for this candidate.

@param entityType  the type of entity
@param similarityThreshold  the accepted threshold of similarity
@return the paginated watchlist hit results

Performs a watchlist search for this candidate .


@NotNull
  public Candidate setDateOfBirth(@Nullable final Date dateOfBirth) {
    if (dateOfBirth == null) {
      this.dateOfBirth = null;
      return this;
    }

    this.dateOfBirth = new Date(dateOfBirth.getTime());
    return this;
  }

@ NotNull public Candidate setDateOfBirth ( @ Nullable final Date dateOfBirth ) { if ( dateOfBirth == null ) { this . dateOfBirth = null ; return this ; } this . dateOfBirth = new Date ( dateOfBirth . getTime ( ) ) ; return this ; }

Set the date of birth of your candidate.

@param dateOfBirth  the date of birth
@return this

Set the date of birth of your candidate .


public Candidate setAddress(@NotNull final Address address) {
    this.addressStreet1 = address.getStreet1();
    this.addressStreet2 = address.getStreet2();
    this.addressCity = address.getCity();
    this.addressSubdivision = address.getSubdivision();
    this.addressPostalCode = address.getPostalCode();
    this.addressCountryCode = address.getCountryCode();
    return this;
  }

public Candidate setAddress ( @ NotNull final Address address ) { this . addressStreet1 = address . getStreet1 ( ) ; this . addressStreet2 = address . getStreet2 ( ) ; this . addressCity = address . getCity ( ) ; this . addressSubdivision = address . getSubdivision ( ) ; this . addressPostalCode = address . getPostalCode ( ) ; this . addressCountryCode = address . getCountryCode ( ) ; return this ; }

Sets the primary street address for this person.

@param address  the primary street address
@return this

Sets the primary street address for this person .


@NotNull
  public Person retrievePerson(@NotNull final String id) {
    Person person = restAdapter.retrievePerson(id);
    person.setAdapter(restAdapter);
    return person;
  }

@ NotNull public Person retrievePerson ( @ NotNull final String id ) { Person person = restAdapter . retrievePerson ( id ) ; person . setAdapter ( restAdapter ) ; return person ; }

Gets a single person exactly as it was when you created it.
This route is useful for auditing purposes as you can provide proof that a verification took place
along with all of its associated data.

@param id  ID of Person.
@return the person, not null

Gets a single person exactly as it was when you created it . This route is useful for auditing purposes as you can provide proof that a verification took place along with all of its associated data .


@NotNull
  public Candidate retrieveCandidate(@NotNull final String id) {
    Candidate candidate = restAdapter.retrieveCandidate(id);
    candidate.setAdapter(restAdapter);
    return candidate;
  }

@ NotNull public Candidate retrieveCandidate ( @ NotNull final String id ) { Candidate candidate = restAdapter . retrieveCandidate ( id ) ; candidate . setAdapter ( restAdapter ) ; return candidate ; }

Retrieves a candidate.

@param id  ID of the candidate.
@return the candidate, not null


@NotNull
  private String getEncodedAuthorization() {
    try {
      return "Basic " + DatatypeConverter.printBase64Binary(apiKey.getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
  }

@
NotNull
private
String
getEncodedAuthorization
(
)
{
try
{
return
"Basic "
+
DatatypeConverter
.
printBase64Binary
(
apiKey
.
getBytes
(
"UTF-8"
)
)
;
}
catch
(
UnsupportedEncodingException
e
)
{
throw
new
RuntimeException
(
e
)
;
}
}

Encodes the API key for Basic authentication.

@return the API key with Base 64 encoding

Encodes the API key for Basic authentication .


@Nullable
  public Date getDateOfBirthEnd() {
    if (birthDayEnd == null || birthMonthEnd == null || birthYearEnd == null) {
      return null;
    }

    GregorianCalendar calendar = new GregorianCalendar(birthYearEnd, birthMonthEnd, birthDayEnd);
    return calendar.getTime();
  }

@ Nullable public Date getDateOfBirthEnd ( ) { if ( birthDayEnd == null || birthMonthEnd == null || birthYearEnd == null ) { return null ; } GregorianCalendar calendar = new GregorianCalendar ( birthYearEnd , birthMonthEnd , birthDayEnd ) ; return calendar . getTime ( ) ; }

Returns the end of the date of birth range.

@return the end of the date of birth range, may be null

Returns the end of the date of birth range .


protected <T> Class<T> getTypeParameter(Class<?> expectedSuperClass, int genericTypeParameterIndex) {
        Class<? extends AbstractScannerPlugin> thisClass = this.getClass();
        if (!thisClass.getSuperclass().equals(expectedSuperClass)) {
            throw new IllegalStateException("Cannot determine type argument of " + thisClass.getName());
        }
        Type genericSuperclass = thisClass.getGenericSuperclass();
        Type typeParameter = ((ParameterizedType) genericSuperclass).getActualTypeArguments()[genericTypeParameterIndex];
        if (typeParameter instanceof ParameterizedType) {
            return (Class<T>) ((ParameterizedType) typeParameter).getRawType();
        }
        return (Class<T>) typeParameter;
    }

protected
<
T
>
Class
<
T
>
getTypeParameter
(
Class
<
>
expectedSuperClass
,
int
genericTypeParameterIndex
)
{
Class
<
extends
AbstractScannerPlugin
>
thisClass
=
this
.
getClass
(
)
;
if
(
!
thisClass
.
getSuperclass
(
)
.
equals
(
expectedSuperClass
)
)
{
throw
new
IllegalStateException
(
"Cannot determine type argument of "
+
thisClass
.
getName
(
)
)
;
}
Type
genericSuperclass
=
thisClass
.
getGenericSuperclass
(
)
;
Type
typeParameter
=
(
(
ParameterizedType
)
genericSuperclass
)
.
getActualTypeArguments
(
)
[
genericTypeParameterIndex
]
;
if
(
typeParameter
instanceof
ParameterizedType
)
{
return
(
Class
<
T
>
)
(
(
ParameterizedType
)
typeParameter
)
.
getRawType
(
)
;
}
return
(
Class
<
T
>
)
typeParameter
;
}

Determines the type parameter for a generic super class.

@param expectedSuperClass
The generic super class.
@param genericTypeParameterIndex
The index, e.g. 0 for the first.
@return The type parameter.

Determines the type parameter for a generic super class .


protected String getStringProperty(String name, String defaultValue) {
        Object value = properties.get(name);
        return value != null ? value.toString() : defaultValue;
    }

protected String getStringProperty ( String name , String defaultValue ) { Object value = properties . get ( name ) ; return value != null ? value . toString ( ) : defaultValue ; }

Get a property as string.

@param name
The name.
@param defaultValue
The default value.
@return The value.


protected Boolean getBooleanProperty(String name, Boolean defaultValue) {
        Object value = properties.get(name);
        return value != null ? Boolean.valueOf(value.toString()) : defaultValue;
    }

protected Boolean getBooleanProperty ( String name , Boolean defaultValue ) { Object value = properties . get ( name ) ; return value != null ? Boolean . valueOf ( value . toString ( ) ) : defaultValue ; }

Get a property as boolean.

@param name
The name.
@param defaultValue
The default value.
@return The value.


protected String getDirectoryPath(File directory, File entry) {
        String relativePath;
        if (entry.equals(directory)) {
            relativePath = "/";
        } else {
            String filePath = entry.getAbsolutePath();
            String directoryPath = directory.getAbsolutePath();
            relativePath = filePath.substring(directoryPath.length()).replace(File.separator, "/");
        }
        return relativePath;
    }

protected String getDirectoryPath ( File directory , File entry ) { String relativePath ; if ( entry . equals ( directory ) ) { relativePath = "/" ; } else { String filePath = entry . getAbsolutePath ( ) ; String directoryPath = directory . getAbsolutePath ( ) ; relativePath = filePath . substring ( directoryPath . length ( ) ) . replace ( File . separator , "/" ) ; } return relativePath ; }

Return the relative path of a file within a directory.

@param directory
The directory.
@param entry
The file.
@return The relative path.

Return the relative path of a file within a directory .


@NotNull
  public BlockscoreErrorType getErrorType() {
    if (type == null) {
      return BlockscoreErrorType.UNKNOWN;
    } else {
      return BlockscoreErrorType.toEnum(type);
    }
  }

@ NotNull public BlockscoreErrorType getErrorType ( ) { if ( type == null ) { return BlockscoreErrorType . UNKNOWN ; } else { return BlockscoreErrorType . toEnum ( type ) ; } }

Gets the error type.
@return the error type


@NotNull
  public ValidationErrorType getValidationErrorCode() {
    if (code == null) {
      return ValidationErrorType.UNKNOWN;
    } else {
      return ValidationErrorType.toEnum(code);
    }
  }

@ NotNull public ValidationErrorType getValidationErrorCode ( ) { if ( code == null ) { return ValidationErrorType . UNKNOWN ; } else { return ValidationErrorType . toEnum ( code ) ; } }

Gets the validation error type.

@return the validation error type


public void flush() {
        createHierarchy();
        sync(fileContainerDescriptor.getRequires(), requiredFiles);
        sync(fileContainerDescriptor.getContains(), containedFiles);
    }

public void flush ( ) { createHierarchy ( ) ; sync ( fileContainerDescriptor . getRequires ( ) , requiredFiles ) ; sync ( fileContainerDescriptor . getContains ( ) , containedFiles ) ; }


private void sync(Collection<FileDescriptor> target, Map<String, FileDescriptor> after) {
        Map<String, FileDescriptor> before = getCache(target);
        Map<String, FileDescriptor> all = new HashMap<>();
        all.putAll(before);
        all.putAll(after);
        for (Map.Entry<String, FileDescriptor> entry : all.entrySet()) {
            String key = entry.getKey();
            FileDescriptor fileDescriptor = entry.getValue();
            boolean hasBefore = before.containsKey(key);
            boolean hasAfter = after.containsKey(key);
            if (hasBefore && !hasAfter) {
                target.remove(fileDescriptor);
            } else if (!hasBefore && hasAfter) {
                target.add(fileDescriptor);
            }
        }
    }

private void sync ( Collection < FileDescriptor > target , Map < String , FileDescriptor > after ) { Map < String , FileDescriptor > before = getCache ( target ) ; Map < String , FileDescriptor > all = new HashMap <> ( ) ; all . putAll ( before ) ; all . putAll ( after ) ; for ( Map . Entry < String , FileDescriptor > entry : all . entrySet ( ) ) { String key = entry . getKey ( ) ; FileDescriptor fileDescriptor = entry . getValue ( ) ; boolean hasBefore = before . containsKey ( key ) ; boolean hasAfter = after . containsKey ( key ) ; if ( hasBefore && ! hasAfter ) { target . remove ( fileDescriptor ) ; } else if ( ! hasBefore && hasAfter ) { target . add ( fileDescriptor ) ; } } }

Sync the given target collection with the new state from the cache map.

@param target The target collection.
@param after  The new state to sync to.

Sync the given target collection with the new state from the cache map .


private Map<String, FileDescriptor> getCache(Iterable<FileDescriptor> fileDescriptors) {
        Map<String, FileDescriptor> cache = new HashMap<>();
        for (FileDescriptor fileDescriptor : fileDescriptors) {
            cache.put(fileDescriptor.getFileName(), fileDescriptor);
        }
        return cache;
    }

private Map < String , FileDescriptor > getCache ( Iterable < FileDescriptor > fileDescriptors ) { Map < String , FileDescriptor > cache = new HashMap <> ( ) ; for ( FileDescriptor fileDescriptor : fileDescriptors ) { cache . put ( fileDescriptor . getFileName ( ) , fileDescriptor ) ; } return cache ; }

Creates cache map from the given collection of file descriptors.

@param fileDescriptors The collection of file descriptors.
@return The cache map.

Creates cache map from the given collection of file descriptors .


private void createHierarchy() {
        for (Map.Entry<String, FileDescriptor> entry : containedFiles.entrySet()) {
            String relativePath = entry.getKey();
            FileDescriptor fileDescriptor = entry.getValue();
            int separatorIndex = relativePath.lastIndexOf('/');
            if (separatorIndex != -1) {
                String parentName = relativePath.substring(0, separatorIndex);
                FileDescriptor parentDescriptor = containedFiles.get(parentName);
                if (parentDescriptor instanceof FileContainerDescriptor) {
                    ((FileContainerDescriptor) parentDescriptor).getContains().add(fileDescriptor);
                }
            }
        }
    }

private void createHierarchy ( ) { for ( Map . Entry < String , FileDescriptor > entry : containedFiles . entrySet ( ) ) { String relativePath = entry . getKey ( ) ; FileDescriptor fileDescriptor = entry . getValue ( ) ; int separatorIndex = relativePath . lastIndexOf ( ' ' ) ; if ( separatorIndex != - 1 ) { String parentName = relativePath . substring ( 0 , separatorIndex ) ; FileDescriptor parentDescriptor = containedFiles . get ( parentName ) ; if ( parentDescriptor instanceof FileContainerDescriptor ) { ( ( FileContainerDescriptor ) parentDescriptor ) . getContains ( ) . add ( fileDescriptor ) ; } } } }

Build the hierarchy of the container entries, i.e. add contains relations
from containers to their children.

Build the hierarchy of the container entries i . e . add contains relations from containers to their children .


public static int findUnusedPort() throws IOException
    {
        int port;

        try (ServerSocket socket = new ServerSocket()) {
            socket.bind(new InetSocketAddress(0));
            port = socket.getLocalPort();
        }

        return port;
    }

public static int findUnusedPort ( ) throws IOException { int port ; try ( ServerSocket socket = new ServerSocket ( ) ) { socket . bind ( new InetSocketAddress ( 0 ) ) ; port = socket . getLocalPort ( ) ; } return port ; }


@Override
    public StringValue getParameterValue(final String _name)
    {
        final List<StringValue> values = this.parameters.get(_name);
        return (values != null && !values.isEmpty()) ? values.get(0)
                        : StringValue.valueOf((String) null);
    }

@ Override public StringValue getParameterValue ( final String _name ) { final List < StringValue > values = this . parameters . get ( _name ) ; return ( values != null && ! values . isEmpty ( ) ) ? values . get ( 0 ) : StringValue . valueOf ( ( String ) null ) ; }

Returns single value for parameter with specified name. This method always returns non-null
result even if the parameter does not exist.

@param _name parameter name
@return {@link StringValue} wrapping the actual value

Returns single value for parameter with specified name . This method always returns non - null result even if the parameter does not exist .


@Override
    public void setParameterValues(final String _name,
                                   final List<StringValue> _value)
    {
        this.parameters.put(_name, _value);
        try {
            Context.getThreadContext().getParameters().put(_name, ParameterUtil.stringValues2Array(_value));
        } catch (final EFapsException e) {
            EFapsRequestParametersAdapter.LOG.error("Could not set parameter '{}' in Context.", _name);
        }
    }

Sets the values for given parameter.

@param _name parameter name
@param _value values


public void setParameterValue(final String _key,
                                  final String _value)
    {
        final List<StringValue> list = new ArrayList<StringValue>(1);
        list.add(StringValue.valueOf(_value));
        setParameterValues(_key, list);
    }

public void setParameterValue ( final String _key , final String _value ) { final List < StringValue > list = new ArrayList < StringValue > ( 1 ) ; list . add ( StringValue . valueOf ( _value ) ) ; setParameterValues ( _key , list ) ; }

Sets value for given key.

@param _key key for the value
@param _value value


public void addParameterValue(final String _key,
                                  final String _value)
    {
        List<StringValue> list = this.parameters.get(_key);
        if (list == null) {
            list = new ArrayList<StringValue>(1);
            this.parameters.put(_key, list);
        }
        list.add(StringValue.valueOf(_value));
        try {
            Context.getThreadContext().getParameters().put(_key, ParameterUtil.stringValues2Array(list));
        } catch (final EFapsException e) {
            EFapsRequestParametersAdapter.LOG.error("Could not add parameter '{}' in Context.", _key);
        }
    }

Adds a value for given key.

@param _key key for the value
@param _value value


public AbstractCommand getTargetCmd()
        throws CacheReloadException
    {
        AbstractCommand cmd = Command.get(this.targetCmdUUID);
        if (cmd == null) {
            cmd = Menu.get(this.targetCmdUUID);
        }
        return cmd;
    }

public AbstractCommand getTargetCmd ( ) throws CacheReloadException { AbstractCommand cmd = Command . get ( this . targetCmdUUID ) ; if ( cmd == null ) { cmd = Menu . get ( this . targetCmdUUID ) ; } return cmd ; }

Get the CommandAbstract that is the target of this Page.

@return the calling CommandAbstract UIClassification
@throws CacheReloadException the cache reload exception
@see #targetCmdUUID

Get the CommandAbstract that is the target of this Page .


protected Object getValue4Wizard(final String _key)
    {
        Object ret = null;
        final Map<String, String[]> para = this.wizard.getParameters((IWizardElement) this);
        if (para != null && para.containsKey(_key)) {
            final String[] value = para.get(_key);
            ret = value[0];
        }
        return ret;
    }

protected Object getValue4Wizard ( final String _key ) { Object ret = null ; final Map < String , String [ ] > para = this . wizard . getParameters ( ( IWizardElement ) this ) ; if ( para != null && para . containsKey ( _key ) ) { final String [ ] value = para . get ( _key ) ; ret = value [ 0 ] ; } return ret ; }

Method to get the value for a key in case of wizard.

@param _key key for the value
@return value for the object, if found, else null

Method to get the value for a key in case of wizard .


public String registerOID(final String _oid)
    {
        final String ret = RandomUtil.randomAlphanumeric(8);
        getUiID2Oid().put(ret, _oid);
        return ret;
    }

public String registerOID ( final String _oid ) { final String ret = RandomUtil . randomAlphanumeric ( 8 ) ; getUiID2Oid ( ) . put ( ret , _oid ) ; return ret ; }

Register oid.

@param _oid the oid
@return the string


@Override
    public Component newNodeComponent(final String _wicketId,
                                      final IModel<UIStructurBrowser> _model)
    {
        return new Node<UIStructurBrowser>(_wicketId, this, _model)
        {

            private static final long serialVersionUID = 1L;

            @Override
            protected Component createContent(final String _wicketId,
                                              final IModel<UIStructurBrowser> _model)
            {
                return newContentComponent(_wicketId, _model);
            }

            @Override
            protected MarkupContainer createJunctionComponent(final String _id)
            {
                final UIStructurBrowser strucBrws = (UIStructurBrowser) getDefaultModelObject();
                final MarkupContainer ret;
                if (strucBrws.hasChildren() && strucBrws.isForceExpanded()) {
                    ret = new WebMarkupContainer(_id);

                } else {
                    ret = super.createJunctionComponent(_id);
                }

                if (strucBrws.getLevel() > 0) {
                    ret.add(AttributeModifier.append("style", "margin-left:" + 15 * (strucBrws.getLevel() - 1) + "px"));
                }
                return ret;
            }
        };
    }

@ Override public Component newNodeComponent ( final String _wicketId , final IModel < UIStructurBrowser > _model ) { return new Node < UIStructurBrowser > ( _wicketId , this , _model ) { private static final long serialVersionUID = 1L ; @ Override protected Component createContent ( final String _wicketId , final IModel < UIStructurBrowser > _model ) { return newContentComponent ( _wicketId , _model ) ; } @ Override protected MarkupContainer createJunctionComponent ( final String _id ) { final UIStructurBrowser strucBrws = ( UIStructurBrowser ) getDefaultModelObject ( ) ; final MarkupContainer ret ; if ( strucBrws . hasChildren ( ) && strucBrws . isForceExpanded ( ) ) { ret = new WebMarkupContainer ( _id ) ; } else { ret = super . createJunctionComponent ( _id ) ; } if ( strucBrws . getLevel ( ) > 0 ) { ret . add ( AttributeModifier . append ( "style" , "margin-left:" + 15 * ( strucBrws . getLevel ( ) - 1 ) + "px" ) ) ; } return ret ; } } ; }

Create a new component for a node.

@param _wicketId  the component id
@param _model     the model containing the node
@return created component


@Override
    public Component newSubtree(final String _wicketId,
                                final IModel<UIStructurBrowser> _model)
    {
        return new SubElement(_wicketId, this, _model);
    }

@ Override public Component newSubtree ( final String _wicketId , final IModel < UIStructurBrowser > _model ) { return new SubElement ( _wicketId , this , _model ) ; }

Create a new subtree.

@param _wicketId     wicket id for this component
@param _model        the model of the new subtree
@return the created component


public static Set<IndexFlavor> complementOf(final Set<IndexFlavor> indexFlavors) {
        final Set<IndexFlavor> set = allOf();
        set.removeAll(indexFlavors);
        return set;
    }

public static Set < IndexFlavor > complementOf ( final Set < IndexFlavor > indexFlavors ) { final Set < IndexFlavor > set = allOf ( ) ; set . removeAll ( indexFlavors ) ; return set ; }

Returns a set containing all the known index flavours, except those is the given set
@param indexFlavors The index flavours which will not be included in the returned set
@return The complement of the given set of index flavours

Returns a set containing all the known index flavours except those is the given set


public static Set<IndexFlavor> of(final IndexFlavor first, final IndexFlavor... rest) {
        final Set<IndexFlavor> set = new HashSet<>();
        set.add(first);
        set.addAll(Arrays.asList(rest));
        return set;
    }

public static Set < IndexFlavor > of ( final IndexFlavor first , final IndexFlavor ... rest ) { final Set < IndexFlavor > set = new HashSet <> ( ) ; set . add ( first ) ; set . addAll ( Arrays . asList ( rest ) ) ; return set ; }

Returns a set containing the given index flavours
@param first The first index flavour to add
@param rest The remaining index flavours to add
@return A set containing the given index flavours


@Override
    public V put(final K key, final V value) {
        entries.add(new Entry(key, value));

        return value;
    }

@ Override public V put ( final K key , final V value ) { entries . add ( new Entry ( key , value ) ) ; return value ; }

Add an entry for the given key-value pair to the map
@param key The key
@param value The value
@return value

Add an entry for the given key - value pair to the map


@Override
    public V remove(final Object key) {
        final Iterator<Map.Entry<K, V>> iterator = entries.iterator();
        V lastValue = null;

        while (iterator.hasNext()) {
            final Map.Entry<K, V> entry = iterator.next();
            lastValue = entry.getValue();

            if (key.equals(entry.getKey())) {
                iterator.remove();
            }
        }

        return lastValue;
    }

@ Override public V remove ( final Object key ) { final Iterator < Map . Entry < K , V > > iterator = entries . iterator ( ) ; V lastValue = null ; while ( iterator . hasNext ( ) ) { final Map . Entry < K , V > entry = iterator . next ( ) ; lastValue = entry . getValue ( ) ; if ( key . equals ( entry . getKey ( ) ) ) { iterator . remove ( ) ; } } return lastValue ; }

Remove all entries for the given key
@param key The key
@return Some value that was paired with the key. The exact value is indeterminate


public String getRandom4ID(final Long _id)
    {
        final String rid = RandomUtil.randomAlphanumeric(8);
        this.random2id.put(rid, _id);
        return rid;
    }

public String getRandom4ID ( final Long _id ) { final String rid = RandomUtil . randomAlphanumeric ( 8 ) ; this . random2id . put ( rid , _id ) ; return rid ; }

Gets the random for ID.

@param _id the id
@return the random for ID


protected List<Integer> getUserWidths()
    {
        List<Integer> ret = null;
        try {
            if (Context.getThreadContext().containsUserAttribute(
                            getCacheKey(UITable.UserCacheKey.COLUMNWIDTH))) {
                setUserWidth(true);
                final String widths = Context.getThreadContext().getUserAttribute(
                                getCacheKey(UITable.UserCacheKey.COLUMNWIDTH));

                final StringTokenizer tokens = new StringTokenizer(widths, ";");

                ret = new ArrayList<>();

                while (tokens.hasMoreTokens()) {
                    final String token = tokens.nextToken();
                    for (int i = 0; i < token.length(); i++) {
                        if (!Character.isDigit(token.charAt(i))) {
                            final int width = Integer.parseInt(token.substring(0, i));
                            ret.add(width);
                            break;
                        }
                    }
                }
            }
        } catch (final NumberFormatException e) {
            // we don't throw an error because this are only Usersettings
            AbstractUIHeaderObject.LOG.error("error during the retrieve of UserAttributes in getUserWidths()", e);
        } catch (final EFapsException e) {
            // we don't throw an error because this are only Usersettings
            AbstractUIHeaderObject.LOG.error("error during the retrieve of UserAttributes in getUserWidths()", e);
        }
        return ret;
    }

This method retieves the UserAttribute for the ColumnWidths and evaluates
the string.

@return List with the values of the columns in Pixel

This method retieves the UserAttribute for the ColumnWidths and evaluates the string .


public void setSortDirection(final SortDirection _sortdirection)
    {
        this.sortDirection = _sortdirection;
        try {
            Context.getThreadContext().setUserAttribute(getCacheKey(UserCacheKey.SORTDIRECTION),
                            _sortdirection.getValue());
        } catch (final EFapsException e) {
            // we don't throw an error because this are only Usersettings
            AbstractUIHeaderObject.LOG.error("error during the retrieve of UserAttributes", e);
        }
    }

Method to set he sort direction.

@param _sortdirection sort direction to set


public void setColumnOrder(final String _markupsIds)
    {
        final StringTokenizer tokens = new StringTokenizer(_markupsIds, ";");
        final StringBuilder columnOrder = new StringBuilder();
        while (tokens.hasMoreTokens()) {
            final String markupId = tokens.nextToken();
            for (final UITableHeader header : getHeaders()) {
                if (markupId.equals(header.getMarkupId())) {
                    columnOrder.append(header.getFieldName()).append(";");
                    break;
                }
            }
        }
        try {
            Context.getThreadContext().setUserAttribute(getCacheKey(UITable.UserCacheKey.COLUMNORDER),
                            columnOrder.toString());
        } catch (final EFapsException e) {
            // we don't throw an error because this are only Usersettings
            AbstractUIHeaderObject.LOG.error("error during the setting of UserAttributes", e);
        }
    }

Method to set the order of the columns.

@param _markupsIds ids of the columns as a string with ; separated

Method to set the order of the columns .


protected List<Field> getUserSortedColumns()
    {
        List<Field> ret = new ArrayList<>();
        try {
            final List<Field> fields = getTable().getFields();
            if (Context.getThreadContext().containsUserAttribute(
                            getCacheKey(UITable.UserCacheKey.COLUMNORDER))) {

                final String columnOrder = Context.getThreadContext().getUserAttribute(
                                getCacheKey(UITable.UserCacheKey.COLUMNORDER));

                final StringTokenizer tokens = new StringTokenizer(columnOrder, ";");
                while (tokens.hasMoreTokens()) {
                    final String fieldname = tokens.nextToken();
                    for (int i = 0; i < fields.size(); i++) {
                        if (fieldname.equals(fields.get(i).getName())) {
                            ret.add(fields.get(i));
                            fields.remove(i);
                        }
                    }
                }
                if (!fields.isEmpty()) {
                    for (final Field field : fields) {
                        ret.add(field);
                    }
                }
            } else {
                ret = fields;
            }
        } catch (final EFapsException e) {
            AbstractUIHeaderObject.LOG.debug("Error on sorting columns");
        }
        return ret;
    }

protected
List
<
Field
>
getUserSortedColumns
(
)
{
List
<
Field
>
ret
=
new
ArrayList
<>
(
)
;
try
{
final
List
<
Field
>
fields
=
getTable
(
)
.
getFields
(
)
;
if
(
Context
.
getThreadContext
(
)
.
containsUserAttribute
(
getCacheKey
(
UITable
.
UserCacheKey
.
COLUMNORDER
)
)
)
{
final
String
columnOrder
=
Context
.
getThreadContext
(
)
.
getUserAttribute
(
getCacheKey
(
UITable
.
UserCacheKey
.
COLUMNORDER
)
)
;
final
StringTokenizer
tokens
=
new
StringTokenizer
(
columnOrder
,
";"
)
;
while
(
tokens
.
hasMoreTokens
(
)
)
{
final
String
fieldname
=
tokens
.
nextToken
(
)
;
for
(
int
i
=
0
;
i
<
fields
.
size
(
)
;
i
++
)
{
if
(
fieldname
.
equals
(
fields
.
get
(
i
)
.
getName
(
)
)
)
{
ret
.
add
(
fields
.
get
(
i
)
)
;
fields
.
remove
(
i
)
;
}
}
}
if
(
!
fields
.
isEmpty
(
)
)
{
for
(
final
Field
field
:
fields
)
{
ret
.
add
(
field
)
;
}
}
}
else
{
ret
=
fields
;
}
}
catch
(
final
EFapsException
e
)
{
AbstractUIHeaderObject
.
LOG
.
debug
(
"Error on sorting columns"
)
;
}
return
ret
;
}

This method looks if for this TableModel a UserAttribute for the sorting
of the Columns exist. If they exist the Fields will be sorted as defined
by the User. If no definition of the User exist the Original default
sorting of the columns will be used. In the Case that the Definition of
the Table was altered Field which are not sorted yet will be sorted in at
the last position.

@return List of fields

This method looks if for this TableModel a UserAttribute for the sorting of the Columns exist . If they exist the Fields will be sorted as defined by the User . If no definition of the User exist the Original default sorting of the columns will be used . In the Case that the Definition of the Table was altered Field which are not sorted yet will be sorted in at the last position .


@Override
    protected void onComponentTag(final ComponentTag _tag)
    {
        super.onComponentTag(_tag);
        final UIStructurBrowser structurBrowser = (UIStructurBrowser) getDefaultModelObject();
        if (structurBrowser.getSortDirection().equals(SortDirection.ASCENDING)) {
            _tag.put("class", "sortLabelAsc");
        } else {
            _tag.put("class", "sortLabelDsc");
        }
    }

@ Override protected void onComponentTag ( final ComponentTag _tag ) { super . onComponentTag ( _tag ) ; final UIStructurBrowser structurBrowser = ( UIStructurBrowser ) getDefaultModelObject ( ) ; if ( structurBrowser . getSortDirection ( ) . equals ( SortDirection . ASCENDING ) ) { _tag . put ( "class" , "sortLabelAsc" ) ; } else { _tag . put ( "class" , "sortLabelDsc" ) ; } }

On the tag the class is set.

@param _tag tag to be set


@Override
    public void onComponentTagBody(final MarkupStream _markupStream,
                                      final ComponentTag _openTag)
    {
        replaceComponentTagBody(_markupStream, _openTag, this.header);
    }

@ Override public void onComponentTagBody ( final MarkupStream _markupStream , final ComponentTag _openTag ) { replaceComponentTagBody ( _markupStream , _openTag , this . header ) ; }

The body of the component is filled with the header.

@param _markupStream MarkupStream
@param _openTag ComponentTag

The body of the component is filled with the header .


@Override
    public void onClick()
    {
        final UIStructurBrowser structurBrowser = (UIStructurBrowser) getDefaultModelObject();
        // toggle sort direction
        if (structurBrowser.getSortDirection() == SortDirection.NONE
                        || structurBrowser.getSortDirection() == SortDirection.DESCENDING) {
            structurBrowser.setSortDirection(SortDirection.ASCENDING);
        } else {
            structurBrowser.setSortDirection(SortDirection.DESCENDING);
        }
        structurBrowser.sort();
        try {
            final Page page;
            if (structurBrowser instanceof UIFieldStructurBrowser) {
                page = new FormPage(Model.of((UIForm) getPage().getDefaultModelObject()));
            } else {
                page = new StructurBrowserPage(Model.of(structurBrowser));
            }
            getRequestCycle().setResponsePage(page);
        } catch (final EFapsException e) {
            getRequestCycle().setResponsePage(new ErrorPage(e));
        }
    }

@
Override
public
void
onClick
(
)
{
final
UIStructurBrowser
structurBrowser
=
(
UIStructurBrowser
)
getDefaultModelObject
(
)
;
// toggle sort direction
if
(
structurBrowser
.
getSortDirection
(
)
==
SortDirection
.
||
structurBrowser
.
getSortDirection
(
)
==
SortDirection
.
DESCENDING
)
{
structurBrowser
.
setSortDirection
(
SortDirection
.
ASCENDING
)
;
}
else
{
structurBrowser
.
setSortDirection
(
SortDirection
.
DESCENDING
)
;
}
structurBrowser
.
sort
(
)
;
try
{
final
Page
page
;
if
(
structurBrowser
instanceof
UIFieldStructurBrowser
)
{
page
=
new
FormPage
(
Model
.
of
(
(
UIForm
)
getPage
(
)
.
getDefaultModelObject
(
)
)
)
;
}
else
{
page
=
new
StructurBrowserPage
(
Model
.
of
(
structurBrowser
)
)
;
}
getRequestCycle
(
)
.
setResponsePage
(
page
)
;
}
catch
(
final
EFapsException
e
)
{
getRequestCycle
(
)
.
setResponsePage
(
new
ErrorPage
(
e
)
)
;
}
}

On click the model is sorted and a new page with this model as response
rendered.

On click the model is sorted and a new page with this model as response rendered .


public static Config getConfig(String name, IConfigFactory factory) {
    if (configs == null) {
      init();
    }
    if (name == null) {
      name = DEFAULT_CONFIG_NAME;
    }

    Config got = configs.get(name);
    if (got == null) {
      log(true, "No Config instance named " + name + "... requesting a new one", null);
      // recheck in synchronized block to avoid double instantiation
      // will block concurrent calls to this Config until
      // the initialization is complete
      synchronized (name.intern()) {
        got = configs.get(name);
        if (got == null) {
          got = factory == null ? load(name) : factory.createConfig(name);
          if (got == null) {
            log(false, "Factory " + factory + " returned a null Config", null);
            throw new InvalidConfigException(
                "Invalid Config returned by " + factory + " factory: null");
          }
          configs.put(name, got);
        }
      }
    }
    return got;
  }

Returns a Config instance, instantiating it on first call. If no factory
implementation is provided, one will be searched using Service Loader If a
Config with given name already exists, it will be simply returned

@param name
- the Config instance name
@param factory
- a custom factory implementation
@return the Config instance with given name, instanciating one if needed

Returns a Config instance instantiating it on first call . If no factory implementation is provided one will be searched using Service Loader If a Config with given name already exists it will be simply returned


private void renderEFapsHeaderItems()
    {
        Collections.sort(this.eFapsHeaderItems, (_item0, _item1) -> _item0.getSortWeight().compareTo(_item1.getSortWeight()));

        final List<String> css = new ArrayList<>();
        final List<String> js = new ArrayList<>();
        for (final AbstractEFapsHeaderItem item : this.eFapsHeaderItems) {
            if (item instanceof EFapsJavaScriptHeaderItem) {
                js.add(item.getReference().getName());
            } else {
                css.add(item.getReference().getName());
            }
        }
        try {
            if (!css.isEmpty()) {
                final String key = BundleMaker.getBundleKey(css, TempFileBundle.class);
                final TempFileBundle bundle = (TempFileBundle) BundleMaker.getBundle(key);
                bundle.setContentType("text/css");
                super.render(CssHeaderItem.forUrl(EFapsApplication.get().getServletContext()
                                .getContextPath() + "/servlet/static/" + key));
            }
            if (!js.isEmpty()) {
                final String key = BundleMaker.getBundleKey(js, TempFileBundle.class);
                final TempFileBundle bundle = (TempFileBundle) BundleMaker.getBundle(key);
                bundle.setContentType("text/javascript");
                super.render(JavaScriptHeaderItem.forUrl(EFapsApplication.get().getServletContext()
                                .getContextPath() + "/servlet/static/" + key));
            }
        } catch (final EFapsException e) {
            EFapsResourceAggregator.LOG.error("Error on rendering eFaps Header items: ", e);
        }
    }


private void renderCombinedRequireScripts()
    {
        final Set<DojoClass> dojoClasses = this.requireHeaderItems.stream().flatMap(o -> o.getDojoClasses().stream())
                        .collect(Collectors.toSet());
        if (CollectionUtils.isNotEmpty(dojoClasses)) {
            super.render(new HeaderItem()
            {

                /** The Constant serialVersionUID. */
                private static final long serialVersionUID = 1L;

                @Override
                public Iterable<?> getRenderTokens()
                {
                    return dojoClasses;
                }

                @Override
                public void render(final Response _response)
                {
                    JavaScriptUtils.writeJavaScript(_response,
                                    DojoWrapper.require(null, dojoClasses.toArray(new DojoClass[dojoClasses.size()])),
                                    RequireHeaderItem.class.getName());
                }
            });
        }
    }

private
void
renderCombinedRequireScripts
(
)
{
final
Set
<
DojoClass
>
dojoClasses
=
this
.
requireHeaderItems
.
stream
(
)
.
flatMap
(
o
->
o
.
getDojoClasses
(
)
.
stream
(
)
)
.
collect
(
Collectors
.
toSet
(
)
)
;
if
(
CollectionUtils
.
isNotEmpty
(
dojoClasses
)
)
{
super
.
render
(
new
HeaderItem
(
)
{
/** The Constant serialVersionUID. */
private
static
final
long
serialVersionUID
=
1L
;
@
Override
public
Iterable
<
>
getRenderTokens
(
)
{
return
dojoClasses
;
}
@
Override
public
void
render
(
final
Response
_response
)
{
JavaScriptUtils
.
writeJavaScript
(
_response
,
DojoWrapper
.
require
(
,
dojoClasses
.
toArray
(
new
DojoClass
[
dojoClasses
.
size
(
)
]
)
)
,
RequireHeaderItem
.
class
.
getName
(
)
)
;
}
}
)
;
}
}


protected CharSequence getCreateTreeNodeScript() {
        final StringBuilder js = new StringBuilder();
        js.append("function(args) {\n")
        .append("var tn = new dijit._TreeNode(args);\n")
        .append("tn.labelNode.innerHTML = args.label;\n")
        .append("var cb = new CheckBox({\n")
        .append("name: '").append(INPUTNAME).append("',\n")
        .append("value: args.item.id,\n")
        .append("checked: args.item.selected,\n")
        .append("onChange: function(b){\n")
        .append("this.focusNode.checked=this.checked;\n")
        .append("\n")
        .append("}\n")
        .append("});\n")
        .append("cb.placeAt(tn.labelNode, 'first');\n")
        .append("tn.cb = cb;\n")
        .append("return tn;\n")
        .append("}\n");
        return js;
    }

Gets the creates the tree node script.

@return the creates the tree node script


protected CharSequence getDataLine(final Classification _clazz, final IClassificationFilter _filter)
        throws EFapsException
    {
        final StringBuilder js = new StringBuilder();
        if (_clazz.hasAccess(null, AccessTypeEnums.SHOW.getAccessType())) {
            js.append(",\n{id:'").append(_clazz.getUUID()).append("', name:'")
                .append(StringEscapeUtils.escapeEcmaScript(_clazz.getLabel())).append("', parent:'")
                .append(_clazz.isRoot() ? "root" : _clazz.getParentClassification().getUUID()).append("', selected:")
                .append(_filter.contains(_clazz.getUUID())).append("}");
            for (final Classification childClazz: _clazz.getChildClassifications()) {
                js.append(getDataLine(childClazz, _filter));
            }
        }
        return js;
    }

protected
CharSequence
getDataLine
(
final
Classification
_clazz
,
final
IClassificationFilter
_filter
)
throws
EFapsException
{
final
StringBuilder
js
=
new
StringBuilder
(
)
;
if
(
_clazz
.
hasAccess
(
,
AccessTypeEnums
.
SHOW
.
getAccessType
(
)
)
)
{
js
.
append
(
",\n{id:'"
)
.
append
(
_clazz
.
getUUID
(
)
)
.
append
(
"', name:'"
)
.
append
(
StringEscapeUtils
.
escapeEcmaScript
(
_clazz
.
getLabel
(
)
)
)
.
append
(
"', parent:'"
)
.
append
(
_clazz
.
isRoot
(
)
"root"
:
_clazz
.
getParentClassification
(
)
.
getUUID
(
)
)
.
append
(
"', selected:"
)
.
append
(
_filter
.
contains
(
_clazz
.
getUUID
(
)
)
)
.
append
(
"}"
)
;
for
(
final
Classification
childClazz
:
_clazz
.
getChildClassifications
(
)
)
{
js
.
append
(
getDataLine
(
childClazz
,
_filter
)
)
;
}
}
return
js
;
}

Gets the data line.

@param _clazz the clazz
@param _filter the filter
@return the data line
@throws EFapsException the e faps exception


public void execute(final Instance _instance)
        throws EFapsException
    {
        UIClassification clazz = this;
        while (!clazz.isRoot()) {
            clazz = clazz.getParent();
        }
        clazz.initialized = true;
        for (final UIClassification child : clazz.getChildren()) {
            final Classification type = (Classification) Type.get(child.getClassificationUUID());
            if (clazz.selectedUUID.contains(child.getClassificationUUID())) {
                child.setSelected(true);
            }
            child.addChildren(child, type.getChildClassifications(), clazz.selectedUUID, _instance);
            clazz.expand();
        }
    }

public void execute ( final Instance _instance ) throws EFapsException { UIClassification clazz = this ; while ( ! clazz . isRoot ( ) ) { clazz = clazz . getParent ( ) ; } clazz . initialized = true ; for ( final UIClassification child : clazz . getChildren ( ) ) { final Classification type = ( Classification ) Type . get ( child . getClassificationUUID ( ) ) ; if ( clazz . selectedUUID . contains ( child . getClassificationUUID ( ) ) ) { child . setSelected ( true ) ; } child . addChildren ( child , type . getChildClassifications ( ) , clazz . selectedUUID , _instance ) ; clazz . expand ( ) ; } }

Execute the model.
@param _instance Instance
@throws EFapsException on error


@SuppressWarnings("unchecked")
    private void expand()
    {
        try {
            final String key = getCacheKey();
            if (Context.getThreadContext().containsSessionAttribute(key)) {
                final Set<UUID> sessMap = (Set<UUID>) Context
                                .getThreadContext().getSessionAttribute(key);
                setExpandedInternal(sessMap.contains(this.classificationUUID));
                for (final UIClassification uiClazz : getDescendants()) {
                    if (sessMap.contains(uiClazz.classificationUUID)) {
                        uiClazz.setExpandedInternal(true);
                    }
                }
            }
        } catch (final EFapsException e) {
            UIClassification.LOG.error("Error reading Session info for UICLassificagtion called by Filed with ID: {}",
                            this.fieldId, e);
        }
    }


private void addChildren(final UIClassification _parent,
                             final Set<Classification> _children,
                             final Set<UUID> _selectedUUID,
                             final Instance _instance)
        throws EFapsException
    {
        for (final Classification child : _children) {
            boolean access;
            if (!child.isAbstract()) {
                final Instance inst = AbstractInstanceObject.getInstance4Create(child);
                access = child.hasAccess(inst, getMode() == TargetMode.CREATE
                                || getMode() == TargetMode.EDIT ? AccessTypeEnums.CREATE.getAccessType()
                                : AccessTypeEnums.SHOW.getAccessType());
            } else {
                access = true;
            }
            if (access) {
                final UIClassification childUI = new UIClassification(child.getUUID(), _parent.mode, false);
                if (_selectedUUID.contains(child.getUUID())) {
                    childUI.selected = true;
                }
                childUI.addChildren(childUI, child.getChildClassifications(), _selectedUUID, _instance);
                _parent.children.add(childUI);
                childUI.setParent(_parent);
            }
        }
        Collections.sort(_parent.children, new Comparator<UIClassification>()
        {
            @Override
            public int compare(final UIClassification _class0,
                               final UIClassification _class2)
            {
                return _class0.getLabel().compareTo(_class2.getLabel());
            }
        });
    }

private void addChildren ( final UIClassification _parent , final Set < Classification > _children , final Set < UUID > _selectedUUID , final Instance _instance ) throws EFapsException { for ( final Classification child : _children ) { boolean access ; if ( ! child . isAbstract ( ) ) { final Instance inst = AbstractInstanceObject . getInstance4Create ( child ) ; access = child . hasAccess ( inst , getMode ( ) == TargetMode . CREATE || getMode ( ) == TargetMode . EDIT ? AccessTypeEnums . CREATE . getAccessType ( ) : AccessTypeEnums . SHOW . getAccessType ( ) ) ; } else { access = true ; } if ( access ) { final UIClassification childUI = new UIClassification ( child . getUUID ( ) , _parent . mode , false ) ; if ( _selectedUUID . contains ( child . getUUID ( ) ) ) { childUI . selected = true ; } childUI . addChildren ( childUI , child . getChildClassifications ( ) , _selectedUUID , _instance ) ; _parent . children . add ( childUI ) ; childUI . setParent ( _parent ) ; } } Collections . sort ( _parent . children , new Comparator < UIClassification > ( ) { @ Override public int compare ( final UIClassification _class0 , final UIClassification _class2 ) { return _class0 . getLabel ( ) . compareTo ( _class2 . getLabel ( ) ) ; } } ) ; }

Recursive method used to add the children to this UIClassification.

@param _parent parent
@param _children children
@param _selectedUUID set of selected classification uuids
@param _instance instance the classifcation belongs to
@throws EFapsException on error

Recursive method used to add the children to this UIClassification .


public Map<UUID, String> getClassInstanceKeys(final Instance _instance)
        throws EFapsException
    {
        final Map<UUID, String> ret = new HashMap<UUID, String>();
        UIClassification clazz = this;
        while (!clazz.isRoot()) {
            clazz = clazz.getParent();
        }
        Type reltype = null;
        for (final UIClassification child : clazz.getChildren()) {
            final Classification classType = (Classification) Type.get(child.getClassificationUUID());
            if (!classType.getClassifyRelationType().equals(reltype)) {
                final QueryBuilder queryBldr = new QueryBuilder(classType.getClassifyRelationType());
                queryBldr.addWhereAttrEqValue(classType.getRelLinkAttributeName(), _instance.getId());
                final MultiPrintQuery multi = queryBldr.getPrint();
                multi.addAttribute(classType.getRelTypeAttributeName());
                multi.execute();
                while (multi.next()) {
                    final Long typeid = multi.<Long>getAttribute(classType.getRelTypeAttributeName());
                    final Classification subClassType = (Classification) Type.get(typeid);
                    final QueryBuilder subQueryBldr = new QueryBuilder(subClassType);
                    subQueryBldr.addWhereAttrEqValue(subClassType.getLinkAttributeName(), _instance.getId());
                    subQueryBldr.addOrderByAttributeAsc("ID");
                    final InstanceQuery query = subQueryBldr.getQuery();
                    query.execute();
                    if (query.next()) {
                        // TODO must return an instanceKey!!! not necessary the
                        // oid
                        final String instanceKey = query.getCurrentValue().getOid();
                        ret.put(query.getCurrentValue().getType().getUUID(), instanceKey);
                        this.selectedUUID.add(query.getCurrentValue().getType().getUUID());
                    }
                }
            }
            reltype = classType.getClassifyRelationType();
        }
        return ret;
    }

Method to get the key to the instances related to this classification.

@param _instance Instance the related instance key are searched for
@return Map of instance keys
@throws EFapsException on error

Method to get the key to the instances related to this classification .


public String getCacheKey()
    {
        String ret = "noKey";
        UIClassification clazz = this;
        while (!clazz.isRoot()) {
            clazz = clazz.getParent();
        }
        final Field field = Field.get(clazz.getFieldId());
        if (field != null) {
            try {
                ret = field.getCollection().getUUID().toString() + "-" + field.getName() + "-"
                                + UIClassification.USERSESSIONKEY;
            } catch (final CacheReloadException e) {
                UIClassification.LOG.error("Cannot generate CacheKey", e);
            }
        }
        return ret;
    }

public
String
getCacheKey
(
)
{
String
ret
=
"noKey"
;
UIClassification
clazz
=
this
;
while
(
!
clazz
.
isRoot
(
)
)
{
clazz
=
clazz
.
getParent
(
)
;
}
final
Field
field
=
Field
.
get
(
clazz
.
getFieldId
(
)
)
;
if
(
field
!=
)
{
try
{
ret
=
field
.
getCollection
(
)
.
getUUID
(
)
.
toString
(
)
+
"-"
+
field
.
getName
(
)
+
"-"
+
UIClassification
.
USERSESSIONKEY
;
}
catch
(
final
CacheReloadException
e
)
{
UIClassification
.
LOG
.
error
(
"Cannot generate CacheKey"
,
e
)
;
}
}
return
ret
;
}

This method generates the Key for a UserAttribute by using the UUID of
the Command and the given static part, so that for every StruturBrowser a
unique key for expand etc, is created.

@return String with the key

This method generates the Key for a UserAttribute by using the UUID of the Command and the given static part so that for every StruturBrowser a unique key for expand etc is created .


public ViewDocumentRequestBuilder addHighlightExpressions(final String highlightExpression, final String... highlightExpressions) {
        this.highlightExpressions.add(highlightExpression);
        this.highlightExpressions.addAll(Arrays.asList(highlightExpressions));
        return this;
    }

public ViewDocumentRequestBuilder addHighlightExpressions ( final String highlightExpression , final String ... highlightExpressions ) { this . highlightExpressions . add ( highlightExpression ) ; this . highlightExpressions . addAll ( Arrays . asList ( highlightExpressions ) ) ; return this ; }

Adds values to the highlight_expression parameter

@param highlightExpression  The first highlight expression
@param highlightExpressions The remaining highlight expressions
@return this


public ViewDocumentRequestBuilder addStartTags(final String startTag, final String... startTags) {
        this.startTags.add(startTag);
        this.startTags.addAll(Arrays.asList(startTags));
        return this;
    }

public ViewDocumentRequestBuilder addStartTags ( final String startTag , final String ... startTags ) { this . startTags . add ( startTag ) ; this . startTags . addAll ( Arrays . asList ( startTags ) ) ; return this ; }

Adds values to the start_tag parameter

@param startTag  The first start tag
@param startTags The remaining start tags
@return this


public ViewDocumentRequestBuilder addEndTags(final String endTag, final String... endTags) {
        this.endTags.add(endTag);
        this.endTags.addAll(Arrays.asList(endTags));
        return this;
    }

public ViewDocumentRequestBuilder addEndTags ( final String endTag , final String ... endTags ) { this . endTags . add ( endTag ) ; this . endTags . addAll ( Arrays . asList ( endTags ) ) ; return this ; }

Adds values to the end_tag parameter

@param endTag  The first end tag
@param endTags The remaining end tags
@return this


public Component getLazyLoadComponent(final String _markupId,
                                          final String _html)
    {
        return new WebMarkupContainer(_markupId)
        {
            /** */
            private static final long serialVersionUID = 1L;

            @Override
            public void onComponentTagBody(final MarkupStream _markupStream,
                                           final ComponentTag _openTag)
            {
                replaceComponentTagBody(_markupStream, _openTag, _html);
            }
        };
    }

public
Component
getLazyLoadComponent
(
final
String
_markupId
,
final
String
_html
)
{
return
new
WebMarkupContainer
(
_markupId
)
{
/** */
private
static
final
long
serialVersionUID
=
1L
;
@
Override
public
void
onComponentTagBody
(
final
MarkupStream
_markupStream
,
final
ComponentTag
_openTag
)
{
replaceComponentTagBody
(
_markupStream
,
_openTag
,
_html
)
;
}
}
;
}

Gets the lazy load component.

@param _markupId the _markup id
@param _html the _html
@return the lazy load component


public Component getLoadingComponent(final String _markupId)
    {
        final IRequestHandler handler = new ResourceReferenceRequestHandler(AbstractDefaultAjaxBehavior.INDICATOR);
        return new Label(_markupId, "<img alt=\"Loading...\" src=\"" + RequestCycle.get().urlFor(handler) + "\"/>")
                        .setEscapeModelStrings(false);
    }

public
Component
getLoadingComponent
(
final
String
_markupId
)
{
final
IRequestHandler
handler
=
new
ResourceReferenceRequestHandler
(
AbstractDefaultAjaxBehavior
.
INDICATOR
)
;
return
new
Label
(
_markupId
,
"<img alt=\"Loading...\" src=\""
+
RequestCycle
.
get
(
)
.
urlFor
(
handler
)
+
"\"/>"
)
.
setEscapeModelStrings
(
false
)
;
}

Gets the loading component.

@param _markupId the markup id
@return The component to show while the real component is being created.


@Override
    public void onClose(final AjaxRequestTarget _target)
    {
        if (this.modalwindow.isUpdateParent()) {
            final Object object = this.pageReference.getPage().getDefaultModelObject();
            try {
                if (object instanceof AbstractUIObject) {

                    final AbstractUIObject uiObject = (AbstractUIObject) object;
                    if (this.clearmodel) {
                        uiObject.resetModel();
                    }
                    AbstractContentPage page = null;

                    if (uiObject instanceof UITable) {
                        page = new TablePage(Model.of((UITable) uiObject), ((AbstractContentPage) this.pageReference
                                        .getPage()).getModalWindow(), ((AbstractContentPage) this.pageReference
                                                        .getPage()).getCalledByPageReference());
                    } else if (uiObject instanceof UIForm) {
                        page = new FormPage(Model.of((UIForm) uiObject), ((AbstractContentPage) this.pageReference
                                        .getPage()).getModalWindow(), ((AbstractContentPage) this.pageReference
                                                        .getPage()).getCalledByPageReference());
                    } else if (uiObject instanceof UIStructurBrowser) {
                        page = new StructurBrowserPage(Model.of((UIStructurBrowser) uiObject),
                                        ((AbstractContentPage) this.pageReference.getPage()).getModalWindow(),
                                        ((AbstractContentPage) this.pageReference.getPage())
                                                        .getCalledByPageReference());
                    }
                    RequestCycle.get().setResponsePage(page);
                } else if (object instanceof UIGrid) {
                    final UIGrid uiGrid = (UIGrid) object;
                    uiGrid.reload();
                    RequestCycle.get().setResponsePage(new GridPage(Model.of(uiGrid)));
                }
            } catch (final EFapsException e) {
                RequestCycle.get().setResponsePage(new ErrorPage(e));
            }
        }
    }

@ Override public void onClose ( final AjaxRequestTarget _target ) { if ( this . modalwindow . isUpdateParent ( ) ) { final Object object = this . pageReference . getPage ( ) . getDefaultModelObject ( ) ; try { if ( object instanceof AbstractUIObject ) { final AbstractUIObject uiObject = ( AbstractUIObject ) object ; if ( this . clearmodel ) { uiObject . resetModel ( ) ; } AbstractContentPage page = null ; if ( uiObject instanceof UITable ) { page = new TablePage ( Model . of ( ( UITable ) uiObject ) , ( ( AbstractContentPage ) this . pageReference . getPage ( ) ) . getModalWindow ( ) , ( ( AbstractContentPage ) this . pageReference . getPage ( ) ) . getCalledByPageReference ( ) ) ; } else if ( uiObject instanceof UIForm ) { page = new FormPage ( Model . of ( ( UIForm ) uiObject ) , ( ( AbstractContentPage ) this . pageReference . getPage ( ) ) . getModalWindow ( ) , ( ( AbstractContentPage ) this . pageReference . getPage ( ) ) . getCalledByPageReference ( ) ) ; } else if ( uiObject instanceof UIStructurBrowser ) { page = new StructurBrowserPage ( Model . of ( ( UIStructurBrowser ) uiObject ) , ( ( AbstractContentPage ) this . pageReference . getPage ( ) ) . getModalWindow ( ) , ( ( AbstractContentPage ) this . pageReference . getPage ( ) ) . getCalledByPageReference ( ) ) ; } RequestCycle . get ( ) . setResponsePage ( page ) ; } else if ( object instanceof UIGrid ) { final UIGrid uiGrid = ( UIGrid ) object ; uiGrid . reload ( ) ; RequestCycle . get ( ) . setResponsePage ( new GridPage ( Model . of ( uiGrid ) ) ) ; } } catch ( final EFapsException e ) { RequestCycle . get ( ) . setResponsePage ( new ErrorPage ( e ) ) ; } } }

Method is executed on close of the modal window.

@param _target Target

Method is executed on close of the modal window .


public void insertBefore(final IWizardElement _element)
    {
        int i = 0;
        for (final IWizardElement uiObject : this.elements) {
            if (uiObject == this.current) {
                this.elements.add(i, _element);
                break;
            }
            i++;
        }
    }

public void insertBefore ( final IWizardElement _element ) { int i = 0 ; for ( final IWizardElement uiObject : this . elements ) { if ( uiObject == this . current ) { this . elements . add ( i , _element ) ; break ; } i ++ ; } }

Insert a UIObject before the current one.

@param _element Object to insert

Insert a UIObject before the current one .


public IWizardElement getPrevious()
    {
        IWizardElement ret = null;
        for (final IWizardElement uiObject : this.elements) {
            if (uiObject == this.current) {
                break;
            } else {
                ret = uiObject;
            }
        }
        this.current = ret;
        return ret;
    }

public IWizardElement getPrevious ( ) { IWizardElement ret = null ; for ( final IWizardElement uiObject : this . elements ) { if ( uiObject == this . current ) { break ; } else { ret = uiObject ; } } this . current = ret ; return ret ; }

Method to get the previous object.

@return previous object


public void addParameters(final IWizardElement _element,
                              final Map<String, String[]> _parameters)
    {
        this.parameters.put(_element, _parameters);
    }

public void addParameters ( final IWizardElement _element , final Map < String , String [ ] > _parameters ) { this . parameters . put ( _element , _parameters ) ; }

Add parameters.

@param _element object used as key
@param _parameters parameters


protected boolean evaluate4Instance()
        throws EFapsException
    {
        boolean ret = true;
        if (!isSearchMode()) {
            final List<Return> returns = this.getCommand().executeEvents(EventType.UI_TABLE_EVALUATE,
                            ParameterValues.INSTANCE, getInstance(),
                            ParameterValues.PARAMETERS, Context.getThreadContext().getParameters(),
                            ParameterValues.CLASS, this);
            for (final Return retu : returns) {
                if (retu.contains(ReturnValues.INSTANCE)) {
                    final Object object = retu.get(ReturnValues.INSTANCE);
                    if (object != null && object instanceof Instance && ((Instance) object).isValid()) {
                        setInstanceKey(((Instance) object).getOid());
                    } else {
                        UIForm.LOG.error("The esjp called by Command '{}' must return a valid instance",
                                        this.getCommand().getName());
                    }
                } else {
                    ret = false;
                }
            }
        }
        return ret;
    }

This is a possibility to replace the current Instance for the form with
another one using an table evaluate esjp.

@return true, if successful
@throws EFapsException on error

This is a possibility to replace the current Instance for the form with another one using an table evaluate esjp .


public void addClassElements(final UIClassification _uiclass,
                                 final Map<UUID, String> _instanceKeys)
        throws EFapsException
    {
        this.elements.addAll(getClassElements(_uiclass, _instanceKeys));
    }

public void addClassElements ( final UIClassification _uiclass , final Map < UUID , String > _instanceKeys ) throws EFapsException { this . elements . addAll ( getClassElements ( _uiclass , _instanceKeys ) ) ; }

Method that adds the classification forms as elements to the form by
walking down the tree.

@param _uiclass the classification to be added
@param _instanceKeys map from uuid to instance keys
@throws EFapsException on error

Method that adds the classification forms as elements to the form by walking down the tree .


public void updateClassElements(final UIClassification _uiclass)
        throws EFapsException
    {
        // remove previous added classification forms
        final Iterator<Element> iter2 = this.elements.iterator();
        final Map<UUID, String> uuid2InstanceKey = new HashMap<>();
        while (iter2.hasNext()) {
            final IFormElement element = iter2.next().getElement();
            if (element instanceof UIFieldForm) {
                final String instanceKey = ((UIFieldForm) element).getInstanceKey();
                final TargetMode mode = ((UIFieldForm) element).getMode();
                if (instanceKey != null && !TargetMode.CREATE.equals(mode)) {
                    final UUID classUUID = ((UIFieldForm) element).getClassificationUUID();
                    uuid2InstanceKey.put(classUUID, instanceKey);
                }
                iter2.remove();
            }
        }
        addClassElements(_uiclass, uuid2InstanceKey);
    }

Method that removes all classifcations and afterwards adds the
classification forms as elements to the form by walking down the tree.

@param _uiclass the classification to be added
@throws EFapsException on error

Method that removes all classifcations and afterwards adds the classification forms as elements to the form by walking down the tree .


private boolean addCell2FormRow(final FormElement _formElement,
                                    final PrintQuery _query,
                                    final Field _field)
        throws EFapsException
    {
        boolean ret = true;
        Attribute attr = null;
        if (_field.getAttribute() != null) {
            attr = _query.getAttribute4Attribute(_field.getAttribute());
        } else if (_field.getSelect() != null) {
            attr = _query.getAttribute4Select(_field.getSelect());
        }

        final Instance fieldInstance = evaluateFieldInstance(_query, _field);
        if (_field.isHiddenDisplay(getMode())) {
            if (_field.getAttribute() != null) {
                _query.getAttribute(_field.getAttribute());
            } else if (_field.getSelect() != null) {
                _query.getSelect(_field.getSelect());
            } else if (_field.getPhrase() != null) {
                _query.getPhrase(_field.getName());
            }
            addHidden(evaluateUIProvider(_query, _field, fieldInstance, attr));
            ret = false;
        } else {
            // fieldset
            if (_field instanceof FieldSet) {
                _formElement.addValue(evaluateFieldSet(_query, _field, fieldInstance));
            } else if (_field instanceof FieldCommand) {
                final UICmdField cell = new UICmdField(this, (FieldCommand) _field, getInstance());
                _formElement.addValue(cell);
            } else if (_field instanceof FieldPicker) {
                final UIField cell = new UIField(this, getInstance().getKey(),
                                UIValue.get(_field, attr, null).setClassObject(this).setInstance(getInstance())
                                    .setCallInstance(getInstance()));
                final UIPicker picker = new UIPicker((FieldPicker) _field, cell);
                cell.setPicker(picker);
                _formElement.addValue(cell);
            } else {
                _formElement.addValue(evaluateUIProvider(_query, _field, fieldInstance, attr));
            }
        }
        return ret;
    }

private
boolean
addCell2FormRow
(
final
FormElement
_formElement
,
final
PrintQuery
_query
,
final
Field
_field
)
throws
EFapsException
{
boolean
ret
=
true
;
Attribute
attr
=
;
if
(
_field
.
getAttribute
(
)
!=
)
{
attr
=
_query
.
getAttribute4Attribute
(
_field
.
getAttribute
(
)
)
;
}
else
if
(
_field
.
getSelect
(
)
!=
)
{
attr
=
_query
.
getAttribute4Select
(
_field
.
getSelect
(
)
)
;
}
final
Instance
fieldInstance
=
evaluateFieldInstance
(
_query
,
_field
)
;
if
(
_field
.
isHiddenDisplay
(
getMode
(
)
)
)
{
if
(
_field
.
getAttribute
(
)
!=
)
{
_query
.
getAttribute
(
_field
.
getAttribute
(
)
)
;
}
else
if
(
_field
.
getSelect
(
)
!=
)
{
_query
.
getSelect
(
_field
.
getSelect
(
)
)
;
}
else
if
(
_field
.
getPhrase
(
)
!=
)
{
_query
.
getPhrase
(
_field
.
getName
(
)
)
;
}
addHidden
(
evaluateUIProvider
(
_query
,
_field
,
fieldInstance
,
attr
)
)
;
ret
=
false
;
}
else
{
// fieldset
if
(
_field
instanceof
FieldSet
)
{
_formElement
.
addValue
(
evaluateFieldSet
(
_query
,
_field
,
fieldInstance
)
)
;
}
else
if
(
_field
instanceof
FieldCommand
)
{
final
UICmdField
cell
=
new
UICmdField
(
this
,
(
FieldCommand
)
_field
,
getInstance
(
)
)
;
_formElement
.
addValue
(
cell
)
;
}
else
if
(
_field
instanceof
FieldPicker
)
{
final
UIField
cell
=
new
UIField
(
this
,
getInstance
(
)
.
getKey
(
)
,
UIValue
.
get
(
_field
,
attr
,
)
.
setClassObject
(
this
)
.
setInstance
(
getInstance
(
)
)
.
setCallInstance
(
getInstance
(
)
)
)
;
final
UIPicker
picker
=
new
UIPicker
(
(
FieldPicker
)
_field
,
cell
)
;
cell
.
setPicker
(
picker
)
;
_formElement
.
addValue
(
cell
)
;
}
else
{
_formElement
.
addValue
(
evaluateUIProvider
(
_query
,
_field
,
fieldInstance
,
attr
)
)
;
}
}
return
ret
;
}

Method to add a Cell to the given Row.

@param _formElement the form element
@param _query query containing the values
@param _field field the cell belongs to
@return true if the cell was actually added, else false
@throws EFapsException on error


private UIField evaluateUIProvider(final PrintQuery _print,
                                       final Field _field,
                                       final Instance _fieldInstance,
                                       final Attribute _attr)
        throws EFapsException
    {
        Object value = null;
        if (_field.getAttribute() != null) {
            value = _print.<Object>getAttribute(_field.getAttribute());
        } else if (_field.getSelect() != null) {
            value = _print.<Object>getSelect(_field.getSelect());
        } else if (_field.getPhrase() != null) {
            value = _print.getPhrase(_field.getName());
        } else if (_field.getMsgPhrase() != null) {
            value = _print.getMsgPhrase(new SelectBuilder(getBaseSelect4MsgPhrase(_field)), _field.getMsgPhrase());
        }
        final UIField uiField = new UIField(this, _fieldInstance.getKey(), UIValue.get(_field, _attr, value)
                        .setInstance(_fieldInstance)
                        .setCallInstance(getInstance())
                        .setClassObject(this));
        return uiField;
    }

private UIField evaluateUIProvider ( final PrintQuery _print , final Field _field , final Instance _fieldInstance , final Attribute _attr ) throws EFapsException { Object value = null ; if ( _field . getAttribute ( ) != null ) { value = _print . < Object > getAttribute ( _field . getAttribute ( ) ) ; } else if ( _field . getSelect ( ) != null ) { value = _print . < Object > getSelect ( _field . getSelect ( ) ) ; } else if ( _field . getPhrase ( ) != null ) { value = _print . getPhrase ( _field . getName ( ) ) ; } else if ( _field . getMsgPhrase ( ) != null ) { value = _print . getMsgPhrase ( new SelectBuilder ( getBaseSelect4MsgPhrase ( _field ) ) , _field . getMsgPhrase ( ) ) ; } final UIField uiField = new UIField ( this , _fieldInstance . getKey ( ) , UIValue . get ( _field , _attr , value ) . setInstance ( _fieldInstance ) . setCallInstance ( getInstance ( ) ) . setClassObject ( this ) ) ; return uiField ; }

Method evaluates a Field and adds it to the row.

@param _print query containing the values
@param _field field the cell belongs to
@param _fieldInstance instance of the Field
@param _attr attribute for the Field
@return the UI field
@throws EFapsException on error

Method evaluates a Field and adds it to the row .


private UIFieldSet evaluateFieldSet(final PrintQuery _query,
                                        final Field _field,
                                        final Instance _fieldInstance)
        throws EFapsException
    {
        final AttributeSet attrSet = AttributeSet.find(getInstance().getType().getName(), _field.getAttribute());

        final Map<?, ?> tmp = (Map<?, ?>) _query.getAttributeSet(_field.getAttribute());

        final List<Instance> fieldins = new ArrayList<>();

        if (tmp != null) {
            fieldins.addAll(_query.getInstances4Attribute(_field.getAttribute()));
        }
        final UIFieldSet ret = new UIFieldSet(this, _fieldInstance,
                        UIValue.get(_field, getInstance().getType().getAttribute(_field.getAttribute()), null));
        ret.setMode(getMode());

        for (final String attrName : ((FieldSet) _field).getOrder()) {
            final Attribute child = attrSet.getAttribute(attrName);
            final UIFieldSetColHeader column = new UIFieldSetColHeader(_field.getLabel(), child, _field);
            ret.addHeader(column);
        }

        final Iterator<Instance> iter = fieldins.iterator();
        final Map<String, Iterator<?>> values = new HashMap<>();
        while (iter.hasNext()) {
            final Instance rowInstance = iter.next();
            ret.addRow(rowInstance);
            for (final String attrName : ((FieldSet) _field).getOrder()) {
                final Attribute child = attrSet.getAttribute(attrName);
                Iterator<?> valIter = values.get(attrName);
                if (valIter == null) {
                    final List<?> tmplist = (List<?>) tmp.get(attrName);
                    valIter = tmplist.iterator();
                    values.put(attrName, valIter);
                }
                final UIValue uiValue = UIValue.get(_field, child, valIter.hasNext() ? valIter.next() : null);
                ret.addValue(rowInstance,
                                new UIFieldSetValue(this, rowInstance.getKey(), ret, uiValue));
            }
        }
        return ret;
    }

private UIFieldSet evaluateFieldSet ( final PrintQuery _query , final Field _field , final Instance _fieldInstance ) throws EFapsException { final AttributeSet attrSet = AttributeSet . find ( getInstance ( ) . getType ( ) . getName ( ) , _field . getAttribute ( ) ) ; final Map < ? , ? > tmp = ( Map < ? , ? > ) _query . getAttributeSet ( _field . getAttribute ( ) ) ; final List < Instance > fieldins = new ArrayList <> ( ) ; if ( tmp != null ) { fieldins . addAll ( _query . getInstances4Attribute ( _field . getAttribute ( ) ) ) ; } final UIFieldSet ret = new UIFieldSet ( this , _fieldInstance , UIValue . get ( _field , getInstance ( ) . getType ( ) . getAttribute ( _field . getAttribute ( ) ) , null ) ) ; ret . setMode ( getMode ( ) ) ; for ( final String attrName : ( ( FieldSet ) _field ) . getOrder ( ) ) { final Attribute child = attrSet . getAttribute ( attrName ) ; final UIFieldSetColHeader column = new UIFieldSetColHeader ( _field . getLabel ( ) , child , _field ) ; ret . addHeader ( column ) ; } final Iterator < Instance > iter = fieldins . iterator ( ) ; final Map < String , Iterator < ? > > values = new HashMap <> ( ) ; while ( iter . hasNext ( ) ) { final Instance rowInstance = iter . next ( ) ; ret . addRow ( rowInstance ) ; for ( final String attrName : ( ( FieldSet ) _field ) . getOrder ( ) ) { final Attribute child = attrSet . getAttribute ( attrName ) ; Iterator < ? > valIter = values . get ( attrName ) ; if ( valIter == null ) { final List < ? > tmplist = ( List < ? > ) tmp . get ( attrName ) ; valIter = tmplist . iterator ( ) ; values . put ( attrName , valIter ) ; } final UIValue uiValue = UIValue . get ( _field , child , valIter . hasNext ( ) ? valIter . next ( ) : null ) ; ret . addValue ( rowInstance , new UIFieldSetValue ( this , rowInstance . getKey ( ) , ret , uiValue ) ) ; } } return ret ; }

Method evaluates a FieldSet and adds it to the row.

@param _query query containing the values
@param _field field the cell belongs to
@param _fieldInstance instance of the FieldSet
@return the UI field set
@throws EFapsException on error

Method evaluates a FieldSet and adds it to the row .


private List<Element> getClassElements(final UIClassification _uiclass,
                                           final Map<UUID, String> _uuid2InstanceKey)
        throws EFapsException
    {
        final List<Element> ret = new ArrayList<>();
        if (_uiclass.isSelected() && !_uiclass.isRoot()) {
            final UIFieldForm fieldform;
            if (_uuid2InstanceKey.containsKey(_uiclass.getClassificationUUID())) {
                fieldform = new UIFieldForm(getCommandUUID(),
                                _uuid2InstanceKey.get(_uiclass.getClassificationUUID()));
            } else {
                fieldform = new UIFieldForm(getCommandUUID(), _uiclass);
                if (isEditMode()) {
                    // in edit mode, if there is no classification yet, create
                    // mode must be forced
                    fieldform.setMode(TargetMode.CREATE);
                }
            }
            ret.add(new Element(ElementType.SUBFORM, fieldform));
        }
        for (final UIClassification child : _uiclass.getChildren()) {
            ret.addAll(getClassElements(child, _uuid2InstanceKey));
        }
        Collections.sort(ret, (_o1,
         _o2) -> ((UIFieldForm) _o1.getElement()).getWeight().compareTo(
                        ((UIFieldForm) _o2.getElement()).getWeight()));
        return ret;
    }

Recursive method to add the children classification forms.

@param _uiclass parent classification form
@param _uuid2InstanceKey mapping of instancekeys
@return List of elements to be added
@throws EFapsException on error

Recursive method to add the children classification forms .


private CharSequence getSubMenuItem(final UIMenuItem _menuItem,
                                        final String _parentNode,
                                        final String _titleNode)
    {
        final StringBuilder js = new StringBuilder();
        final String node1 = RandomUtil.randomAlphabetic(4);

        if (_menuItem.getChildren().isEmpty()) {
            js.append(" on(").append(_titleNode).append(", \"click\", function(evt) {\n")
                .append(getEventJs(_menuItem))
                .append("});\n");
        } else {
            js.append("var ").append(node1).append(" = domConstruct.create(\"div\",")
                .append("{ class: \"nested\", style: \"display:none\"}, ")
                .append(_parentNode).append(");\n")
                .append(" on(").append(_titleNode).append(", \"click\", function(evt) {\n")
                .append("if (domStyle.get(").append(node1).append(", \"display\") !== \"none\") {\n")
                .append(" domClass.replace(evt.currentTarget, \"closed\", \"open\"); \n")
                .append("fx.wipeOut({\n")
                .append("node: ").append(node1).append("\n")
                .append("}).play();\n")
                .append("} else {\n")
                .append(" domClass.replace(evt.currentTarget, \"open\", \"closed\"); \n")
                .append("fx.wipeIn({\n")
                .append("node: ").append(node1).append("\n")
                .append("}).play();\n")
                .append("}\n")
                .append("});\n");
        }
        for (final UIMenuItem childItem : _menuItem.getChildren()) {
            final String node2 = RandomUtil.randomAlphabetic(4);
            final String node3 = RandomUtil.randomAlphabetic(4);
            js.append("var ").append(node2).append(" = domConstruct.create(\"div\",")
                .append("{ class: \"menueentry\"}, ").append(node1).append(");\n")
                .append("var ").append(node3).append(" = domConstruct.create(\"div\", { class: \"title");
            if (!childItem.getChildren().isEmpty()) {
                js.append(" closed");
            }
            js.append("\"},").append(node2).append(");\n")
                .append(getImage(childItem, node3))
                .append("domConstruct.create(\"span\", { class: \"menutitle\", innerHTML: \"")
                .append(StringEscapeUtils.escapeEcmaScript(StringEscapeUtils.escapeHtml4(childItem.getLabel())))
                .append("\"} , ").append(node3).append("); \n")
                .append(getSubMenuItem(childItem, node2, node3));
        }
        return js;
    }

Gets the sub menu item.

@param _menuItem the menu item
@param _parentNode the parent node
@param _titleNode the title node
@return the sub menu item


private CharSequence getEventJs(final UIMenuItem _menuItem)
    {
        final String key = RandomUtil.randomAlphabetic(8);
        this.menuItems.put(key, _menuItem);
        final StringBuilder ret = new StringBuilder();
        switch (_menuItem.getTarget()) {
            case HIDDEN:
                ret.append(getBehavior(ExecBehavior.class).getCallbackFunctionBody(CallbackParameter.converted("m",
                                "\"" + key + "\"")));
                break;
            case MODAL:
                ret.append(getBehavior(OpenModalBehavior.class).getCallbackFunctionBody(CallbackParameter.converted("m",
                                "\"" + key + "\"")));
                break;
            case POPUP:
                final PageParameters popupPageParameters = new PageParameters();
                popupPageParameters.add("m", key);
                final PopupSettings popupSettings = new PopupSettings();
                popupSettings.setHeight(_menuItem.getWindowHeight());
                popupSettings.setWidth(_menuItem.getWindowWidth());
                popupSettings.setTarget("'" + urlForListener(popupPageParameters) + "'");
                popupSettings.setWindowName("eFapsPopup");
                ret.append("(function () {").append(popupSettings.getPopupJavaScript()).append("}) ();");
                break;
            default:
                final PageParameters pageParameters = new PageParameters();
                pageParameters.add("m", key);
                ret.append("registry.byId(\"").append("mainPanel").append(
                                "\").set(\"content\", domConstruct.create(\"iframe\", {").append("\"id\": \"")
                        .append(MainPage.IFRAME_ID).append("\",\"src\": \"").append(urlForListener(pageParameters))
                        .append("\",\"style\": \"border: 0; width: 100%; height: 99%\"").append(",\"id\": \"")
                        .append(MainPage.IFRAME_ID).append("\"").append("}));");
                break;
        }
        return ret;
    }

Gets the url.

@param _menuItem the menu item
@return the url


private CharSequence getImage(final UIMenuItem _menuItem,
                                  final String _node)
    {
        final String label = _menuItem.getLabel();
        String content = "";
        if (StringUtils.isNotEmpty(label)) {
            content = StringUtils.left(label, 1).toUpperCase();
        }
        final StringBuilder js = new StringBuilder();
        if (StringUtils.isNotEmpty(_menuItem.getImage()) && _menuItem.getImage().endsWith(".svg")) {
            try {
                final QueryBuilder querBldr = new QueryBuilder(CIAdminUserInterface.Image);
                querBldr.addWhereAttrEqValue(CIAdminUserInterface.Image.Name, _menuItem.getImage());
                final InstanceQuery query = querBldr.getQuery();
                query.execute();
                if (query.next()) {
                    final Checkout checkout = new Checkout(query.getCurrentValue());
                    final ByteArrayOutputStream os = new ByteArrayOutputStream();
                    checkout.execute(os);
                    final String svg = new String(os.toByteArray(), StandardCharsets.UTF_8);
                    js.append("domConstruct.create(\"span\", {\n")
                        .append("innerHTML: \"").append(StringEscapeUtils.escapeEcmaScript(svg)).append("\"\n")
                        .append("}, ").append(_node).append(");\n");
                }
            } catch (final EFapsException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } else {
            js.append("domConstruct.create(\"span\", {\n")
                .append("class: \"circle ").append(content).append(" \"\n,")
                .append("innerHTML: \"").append(content).append("\"\n")
                .append("}, ").append(_node).append(");\n");
        }
        return js;
    }

private
CharSequence
getImage
(
final
UIMenuItem
_menuItem
,
final
String
_node
)
{
final
String
label
=
_menuItem
.
getLabel
(
)
;
String
content
=
""
;
if
(
StringUtils
.
isNotEmpty
(
label
)
)
{
content
=
StringUtils
.
left
(
label
,
1
)
.
toUpperCase
(
)
;
}
final
StringBuilder
js
=
new
StringBuilder
(
)
;
if
(
StringUtils
.
isNotEmpty
(
_menuItem
.
getImage
(
)
)
&&
_menuItem
.
getImage
(
)
.
endsWith
(
".svg"
)
)
{
try
{
final
QueryBuilder
querBldr
=
new
QueryBuilder
(
CIAdminUserInterface
.
Image
)
;
querBldr
.
addWhereAttrEqValue
(
CIAdminUserInterface
.
Image
.
Name
,
_menuItem
.
getImage
(
)
)
;
final
InstanceQuery
query
=
querBldr
.
getQuery
(
)
;
query
.
execute
(
)
;
if
(
query
.
next
(
)
)
{
final
Checkout
checkout
=
new
Checkout
(
query
.
getCurrentValue
(
)
)
;
final
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
(
)
;
checkout
.
execute
(
os
)
;
final
String
svg
=
new
String
(
os
.
toByteArray
(
)
,
StandardCharsets
.
UTF_8
)
;
js
.
append
(
"domConstruct.create(\"span\", {\n"
)
.
append
(
"innerHTML: \""
)
.
append
(
StringEscapeUtils
.
escapeEcmaScript
(
svg
)
)
.
append
(
"\"\n"
)
.
append
(
"}, "
)
.
append
(
_node
)
.
append
(
");\n"
)
;
}
}
catch
(
final
EFapsException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
(
)
;
}
}
else
{
js
.
append
(
"domConstruct.create(\"span\", {\n"
)
.
append
(
"class: \"circle "
)
.
append
(
content
)
.
append
(
" \"\n,"
)
.
append
(
"innerHTML: \""
)
.
append
(
content
)
.
append
(
"\"\n"
)
.
append
(
"}, "
)
.
append
(
_node
)
.
append
(
");\n"
)
;
}
return
js
;
}

Gets the image.

@param _menuItem the menu item
@param _node the node
@return the image


protected AjaxEventBehavior getBehavior(final Class<? extends Behavior> _class)
    {
        final SlideInPanel panel = (SlideInPanel) getParent();
        return panel.visitChildren(AjaxMenuItem.class, (_item,
         _visit) -> {
            final List<? extends Behavior> behaviors = _item.getBehaviors(_class);
            if (CollectionUtils.isNotEmpty(behaviors)) {
                _visit.stop((AjaxEventBehavior) behaviors.get(0));
            } else {
                _visit.stop();
            }
        });
    }

protected AjaxEventBehavior getBehavior ( final Class < ? extends Behavior > _class ) { final SlideInPanel panel = ( SlideInPanel ) getParent ( ) ; return panel . visitChildren ( AjaxMenuItem . class , ( _item , _visit ) -> { final List < ? extends Behavior > behaviors = _item . getBehaviors ( _class ) ; if ( CollectionUtils . isNotEmpty ( behaviors ) ) { _visit . stop ( ( AjaxEventBehavior ) behaviors . get ( 0 ) ) ; } else { _visit . stop ( ) ; } } ) ; }

Gets the behavior.

@param _class the class
@return the behavior


public void addComponents(final Model<UIHeading> _headingmodel)
    {
        final WebMarkupContainer container = new WebMarkupContainer("container");

        this.add(container);
        if (_headingmodel.getObject().getLevel() == 0) {
            container.add(AttributeModifier.replace("class", "eFapsFrameTitle"));
        } else {
            container.add(AttributeModifier.replace("class", "eFapsHeading" + _headingmodel.getObject().getLevel()));
        }
        container.add(new Label("heading", _headingmodel.getObject().getLabel()));

        final String toggleId = this.getMarkupId(true);
        final Component span = new WebComponent("toggle") {

            private static final long serialVersionUID = 1L;

            @Override
            protected void onComponentTag(final ComponentTag _tag)
            {
                super.onComponentTag(_tag);
                _tag.put("onclick", "toggleSection('" + toggleId + "');");
            }

            @Override
            public boolean isVisible()
            {
                return _headingmodel.getObject().getLevel() > 0 && _headingmodel.getObject().isCollapsible();
            }
        };
        container.add(span);

        final Component status = new WebComponent("status") {

            private static final long serialVersionUID = 1L;

            @Override
            protected void onComponentTag(final ComponentTag _tag)
            {
                super.onComponentTag(_tag);
                _tag.put("name", _headingmodel.getObject().getName());
                _tag.put("value", false);
            }

            @Override
            public boolean isVisible()
            {
                return _headingmodel.getObject().getLevel() > 0 && _headingmodel.getObject().isCollapsible();
            }
        };
        status.setMarkupId("status_" + toggleId);
        container.add(status);
    }

public void addComponents ( final Model < UIHeading > _headingmodel ) { final WebMarkupContainer container = new WebMarkupContainer ( "container" ) ; this . add ( container ) ; if ( _headingmodel . getObject ( ) . getLevel ( ) == 0 ) { container . add ( AttributeModifier . replace ( "class" , "eFapsFrameTitle" ) ) ; } else { container . add ( AttributeModifier . replace ( "class" , "eFapsHeading" + _headingmodel . getObject ( ) . getLevel ( ) ) ) ; } container . add ( new Label ( "heading" , _headingmodel . getObject ( ) . getLabel ( ) ) ) ; final String toggleId = this . getMarkupId ( true ) ; final Component span = new WebComponent ( "toggle" ) { private static final long serialVersionUID = 1L ; @ Override protected void onComponentTag ( final ComponentTag _tag ) { super . onComponentTag ( _tag ) ; _tag . put ( "onclick" , "toggleSection('" + toggleId + "');" ) ; } @ Override public boolean isVisible ( ) { return _headingmodel . getObject ( ) . getLevel ( ) > 0 && _headingmodel . getObject ( ) . isCollapsible ( ) ; } } ; container . add ( span ) ; final Component status = new WebComponent ( "status" ) { private static final long serialVersionUID = 1L ; @ Override protected void onComponentTag ( final ComponentTag _tag ) { super . onComponentTag ( _tag ) ; _tag . put ( "name" , _headingmodel . getObject ( ) . getName ( ) ) ; _tag . put ( "value" , false ) ; } @ Override public boolean isVisible ( ) { return _headingmodel . getObject ( ) . getLevel ( ) > 0 && _headingmodel . getObject ( ) . isCollapsible ( ) ; } } ; status . setMarkupId ( "status_" + toggleId ) ; container . add ( status ) ; }

Method to add the Component to this Panel.

@param _headingmodel model of the heading.

Method to add the Component to this Panel .


@Override
    public Iterator<? extends UIStructurBrowser> getChildren(final UIStructurBrowser _node)
    {
        if (_node.isParent() && !_node.hasChildren()) {
            _node.addChildren();
        }
        return _node.getChildren().iterator();
    }

@ Override public Iterator < ? extends UIStructurBrowser > getChildren ( final UIStructurBrowser _node ) { if ( _node . isParent ( ) && ! _node . hasChildren ( ) ) { _node . addChildren ( ) ; } return _node . getChildren ( ) . iterator ( ) ; }

Get the children of the given node.

@param _node node to get children for
@return children of node


public <U, BE extends EntityType, BT extends TokenType> U makeRequest(
        final TokenProxy<BE, BT> tokenProxy,
        final Class<U> returnType,
        final BackendCaller<? super BE, ? super BT> backendCaller
    ) throws HodErrorException {
        return responseParser.parseResponse(tokenProxy, returnType, backendCaller.makeRequest(getAuthenticationToken(tokenProxy)));
    }

public < U , BE extends EntityType , BT extends TokenType > U makeRequest ( final TokenProxy < BE , BT > tokenProxy , final Class < U > returnType , final BackendCaller < ? super BE , ? super BT > backendCaller ) throws HodErrorException { return responseParser . parseResponse ( tokenProxy , returnType , backendCaller . makeRequest ( getAuthenticationToken ( tokenProxy ) ) ) ; }

Makes a request to HP Haven OnDemand, converting the response body to the type specified by the Class object.
@param tokenProxy The token proxy to use to make the request
@param returnType The desired type of the value returned by HP Haven OnDemand
@param backendCaller Makes the request to HP Haven OnDemand
@param <U> The desired type of the value returned by HP Haven OnDemand
@param <BE> The entity type of the token proxy
@param <BT> The token type of the token proxy
@return An object representing the output from HP Haven OnDemand
@throws HodErrorException

Makes a request to HP Haven OnDemand converting the response body to the type specified by the Class object .


public <U, BE extends EntityType, BT extends TokenType> U makeRequest(
        final TokenProxy<BE, BT> tokenProxy,
        final TypeReference<U> typeReference,
        final BackendCaller<? super BE, ? super BT> backendCaller
    ) throws HodErrorException {
        return responseParser.parseResponse(tokenProxy, typeReference, backendCaller.makeRequest(getAuthenticationToken(tokenProxy)));
    }

public < U , BE extends EntityType , BT extends TokenType > U makeRequest ( final TokenProxy < BE , BT > tokenProxy , final TypeReference < U > typeReference , final BackendCaller < ? super BE , ? super BT > backendCaller ) throws HodErrorException { return responseParser . parseResponse ( tokenProxy , typeReference , backendCaller . makeRequest ( getAuthenticationToken ( tokenProxy ) ) ) ; }

Makes a request to HP Haven OnDemand, converting the response body to the type specified by the type reference.
@param tokenProxy The token proxy to use to make the request
@param typeReference The desired type of the value returned by HP Haven OnDemand
@param backendCaller Makes the request to HP Haven OnDemand
@param <U> The desired type of the value returned by HP Haven OnDemand
@param <BE> The entity type of the token proxy
@param <BT> The token type of the token proxy
@return An object representing the output from HP Haven OnDemand
@throws HodErrorException

Makes a request to HP Haven OnDemand converting the response body to the type specified by the type reference .


public <BE extends EntityType, BT extends TokenType> InputStream makeRequest(
        final TokenProxy<BE, BT> tokenProxy,
        final BackendCaller<? super BE, ? super BT> backendCaller
    ) throws HodErrorException {
        return responseParser.parseResponse(tokenProxy, backendCaller.makeRequest(getAuthenticationToken(tokenProxy)));
    }

public < BE extends EntityType , BT extends TokenType > InputStream makeRequest ( final TokenProxy < BE , BT > tokenProxy , final BackendCaller < ? super BE , ? super BT > backendCaller ) throws HodErrorException { return responseParser . parseResponse ( tokenProxy , backendCaller . makeRequest ( getAuthenticationToken ( tokenProxy ) ) ) ; }

Makes a request to HP Haven OnDemand, returning the response body as an input stream.
@param tokenProxy The token proxy to use to make the request
@param backendCaller Makes the request to HP Haven OnDemand
@param <BE> The entity type of the token proxy
@param <BT> The token type of the token proxy
@return The response body
@throws HodErrorException

Makes a request to HP Haven OnDemand returning the response body as an input stream .


public <U, BE extends EntityType, BT extends TokenType> U unsafeMakeRequest(
        final TokenProxy<BE, BT> tokenProxy,
        final JavaType type,
        final BackendCaller<? super BE, ? super BT> backendCaller
    ) throws HodErrorException {
        return responseParser.unsafeParseResponse(tokenProxy, type, backendCaller.makeRequest(getAuthenticationToken(tokenProxy)));
    }

public < U , BE extends EntityType , BT extends TokenType > U unsafeMakeRequest ( final TokenProxy < BE , BT > tokenProxy , final JavaType type , final BackendCaller < ? super BE , ? super BT > backendCaller ) throws HodErrorException { return responseParser . unsafeParseResponse ( tokenProxy , type , backendCaller . makeRequest ( getAuthenticationToken ( tokenProxy ) ) ) ; }

Makes a request to HP Haven OnDemand, converting the response body to the type specified by the JavaType. This
method does not guarantee that the type parameter U represents the given JavaType. If possible, use one of the
safe makeRequest methods instead.
@param tokenProxy The token proxy to use to make the request
@param type The desired type of the value returned by HP Haven OnDemand
@param backendCaller Makes the request to HP Haven OnDemand
@param <U> The desired type of the value returned by HP Haven OnDemand
@param <BE> The entity type of the token proxy
@param <BT> The token type of the token proxy
@return An object representing the output from HP Haven OnDemand
@throws HodErrorException

Makes a request to HP Haven OnDemand converting the response body to the type specified by the JavaType . This method does not guarantee that the type parameter U represents the given JavaType . If possible use one of the safe makeRequest methods instead .