= TableColumnOrderServiceUsingTxtFile
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Provides a simple mechanism to order the columns of both parented and standalone collections by reading a flat file containing the list of the associations (usually properties, but collections are also supported), in the desired order, one associationId per line.

The files are located relative to the class itself. A number of conventions are supported:

* for parented collections:
+
--
(where '_' is a wildcard for any collection of the element type
--
+
--

* `ParentClassName#collectionId.columnOrder.txt`
* `ParentClassName#collectionId.columnOrder.fallback.txt`
* `ParentClassName#_.ElementTypeClassName.columnOrder.txt`
* `ParentClassName#_.ElementTypeClassName.columnOrder.fallback.txt`
* `ElementTypeClassName.columnOrder.txt`
* `ElementTypeClassName.columnOrder.fallback.txt`
--
* for standalone collections:
+
--

* `DomainTypeClassName.columnOrder.txt`
* `DomainTypeClassName.columnOrder.fallback.txt`
--

Any associations omitted from the file will not be shown as columns of the table. The associationId must also be an exact match, so can be ignored by commenting out, eg with "#".

Also note that association that have been explicitly hidden from tables using _PropertyLayout#hidden() @PropertyLayout#hidden_ or _CollectionLayout#hidden()_ are never shown, irrespective of whether they are listed in the files. You may therefore prefer to _not_ hide properties with annotations, and then rely solely on these external _columnOrder.txt_ files. This has the further benefit that files can be modified at runtime and will be automatically picked up without requiring a restart of the application.

== API

[source,java]
.TableColumnOrderServiceUsingTxtFile.java
----
class TableColumnOrderServiceUsingTxtFile {
  List<String> orderParented(Object domainObject, String collectionId, Class<?> elementType, List<String> associationIds)     // <.>
  List<String> orderStandalone(Class<?> domainType, List<String> associationIds)     // <.>
}
----

<.> xref:#orderParented_Object_String_Class_List[orderParented(Object, String, Class, List)]
+
--
Reads association Ids of the parented collection from a file.
--
<.> xref:#orderStandalone_Class_List[orderStandalone(Class, List)]
+
--
Reads associationIds of a standalone collection from a file.
--

== Members

[#orderParented_Object_String_Class_List]
=== orderParented(Object, String, Class, List)

Reads association Ids of the parented collection from a file.

The search algorithm is:

* `ParentClassName#collectionId.columnOrder.txt`
* `ParentClassName#collectionId.columnOrder.fallback.txt`
* `ParentClassName#_.ElementTypeClassName.columnOrder.txt`
+
--
(where '_' is a wildcard for any collection of the element type
--
* `ParentClassName#_.ElementTypeClassName.columnOrder.fallback.txt`
* `ElementTypeClassName.columnOrder.txt`
* `ElementTypeClassName.columnOrder.fallback.txt`

Additional files can be provided by overriding _#addResourceNames(Class, String, Class, List)_

[#orderStandalone_Class_List]
=== orderStandalone(Class, List)

Reads associationIds of a standalone collection from a file.

The search algorithm is:

* `DomainTypeClassName.columnOrder.txt`
* `DomainTypeClassName.columnOrder.fallback.txt`

Additional files can be provided by overriding _#addResourceNames(Class, List)_ .
