[jira] [Resolved] (SIS-298) Simplification in MetadataTreeFormat output

2017-05-03 Thread Martin Desruisseaux (JIRA)

 [ 
https://issues.apache.org/jira/browse/SIS-298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Desruisseaux resolved SIS-298.
-
Resolution: Fixed

> Simplification in MetadataTreeFormat output
> ---
>
> Key: SIS-298
> URL: https://issues.apache.org/jira/browse/SIS-298
> Project: Spatial Information Systems
>  Issue Type: Improvement
>  Components: Metadata
>Affects Versions: 0.3, 0.4, 0.5, 0.6, 0.7
>Reporter: Martin Desruisseaux
>Assignee: Martin Desruisseaux
>Priority: Minor
> Fix For: 0.8
>
>
> We could simplify and clarify a little bit the tree produced by the 
> {{MetadataTreeFormat}} by using two additional rules:
> h3. Use less lines in simple case
> If a property has the same name than the parent property that contains it, we 
> could write its value in that parent property. For example instead of:
> {noformat}
> Citation
>  └─Date
> ├─Date 2012/01/01
> └─Date type …… Creation
> {noformat}
> We could simplify as:
> {noformat}
> Citation
>  └─Date……… 2012/01/01
> └─Date type …… Creation
> {noformat}
> h3. Tell the sub-type
> If a property has the same name than the value type, and if that value type 
> has sub-type, we could format the actual value sub-type in the tree. For 
> example {{Citation}} as a property named {{party}} of type {{Party}} 
> (ignoring multi-occurrences). But {{Party}} has two sub-types: {{Individual}} 
> and {{Organisation}}. So instead of:
> {noformat}
> Citation
>  └─Cited responsible party
> └─Party
>└─Name  Jon Smith
> {noformat}
> It would be helpful to format:
> {noformat}
> Citation
>  └─Cited responsible party
> └─Individual
>└─Name  Jon Smith
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


svn commit: r1793725 - in /sis/branches/JDK8: core/sis-metadata/src/main/java/org/apache/sis/metadata/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ core/sis-metadata/src/main/java/org/

2017-05-03 Thread desruisseaux
Author: desruisseaux
Date: Wed May  3 22:11:48 2017
New Revision: 1793725

URL: http://svn.apache.org/viewvc?rev=1793725=rev
Log:
More simplification of metadata tree.

Modified:

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/AbstractParty.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureTypeInfo.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeElementDescription.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDistribution.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultKeywordClass.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultOperationChainMetadata.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultOperationMetadata.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultUsage.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultProcessStepReport.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultSource.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultDimension.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGCPCollection.java

sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java

sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeTest.java

sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableFormatTest.java

sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java

sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java

sis/branches/JDK8/storage/sis-earth-observation/src/test/java/org/apache/sis/storage/earthobservation/LandsatReaderTest.java

sis/branches/JDK8/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java

Modified: 
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java?rev=1793725=1793724=1793725=diff
==
--- 
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
 [UTF-8] Wed May  3 22:11:48 2017
@@ -146,7 +146,13 @@ final class TreeNodeChildren extends Abs
  * That property shall be a singleton for a simple value (not another 
metadata object).
  */
 if (parent.getParent() != null) {
-final TitleProperty an = 
accessor.implementation.getAnnotation(TitleProperty.class);
+TitleProperty an = 
accessor.implementation.getAnnotation(TitleProperty.class);
+if (an == null) {
+Class implementation = 
parent.table.standard.getImplementation(accessor.type);
+if (implementation != null) {
+an = implementation.getAnnotation(TitleProperty.class);
+}
+}
 if (an != null) {
 final int index = accessor.indexOf(an.name(), false);
 final Class type = accessor.type(index, 
TypeValuePolicy.ELEMENT_TYPE);

Modified: 
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java?rev=1793725=1793724=1793725=diff
==
--- 
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
 [UTF-8] (original)
+++ 

svn commit: r1793684 - in /sis/branches/JDK8: core/sis-metadata/src/main/java/org/apache/sis/metadata/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ core/sis-metadata/src/main/java/org/

2017-05-03 Thread desruisseaux
Author: desruisseaux
Date: Wed May  3 17:41:30 2017
New Revision: 1793684

URL: http://svn.apache.org/viewvc?rev=1793684=rev
Log:
First draft of tree view simplification.
https://issues.apache.org/jira/browse/SIS-298

Modified:

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitationDate.java

sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultExtent.java

sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java

sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeTest.java

sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableFormatTest.java

sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java

sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentificationTest.java

sis/branches/JDK8/storage/sis-earth-observation/src/test/java/org/apache/sis/storage/earthobservation/LandsatReaderTest.java

sis/branches/JDK8/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java

Modified: 
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java?rev=1793684=1793683=1793684=diff
==
--- 
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
 [UTF-8] Wed May  3 17:41:30 2017
@@ -178,12 +178,20 @@ class TreeNode implements Node {
 this.parent   = parent;
 this.metadata = metadata;
 this.baseType = baseType;
-if (!table.standard.isMetadata(baseType)) {
+if (!isMetadata(baseType)) {
 children = LEAF;
 }
 }
 
 /**
+ * Returns {@code true} if nodes for values of the given type can be 
expanded with more children.
+ * A return value of {@code false} means that values of the given type are 
leaves.
+ */
+final boolean isMetadata(final Class type) {
+return table.standard.isMetadata(type);
+}
+
+/**
  * Returns the key to use for calls to {@link MetadataStandard} methods.
  * This key is used only for some default method implementations in the 
root node;
  * children will use the class of their node value instead.
@@ -390,7 +398,7 @@ class TreeNode implements Node {
 Class type = null;
 for (Class c : subtypes) {
 if (baseType.isAssignableFrom(c)) {
-if (!table.standard.isMetadata(c)) {
+if (!isMetadata(c)) {
 c = standardSubType(c.getInterfaces());
 }
 if (type == null) {
@@ -645,19 +653,14 @@ class TreeNode implements Node {
 cachedValue = null; // Use the cached value only once 
after iteration.
 /*
  * If there is a value, check if the cached collection is still 
applicable.
+ * We verify that the collection is a wrapper for the same 
metadata object.
+ * If we need to create a new collection, we know that the 
property accessor
+ * exists otherwise the call to 'isLeaf()' above would have 
returned 'true'.
  */
-if (children instanceof TreeNodeChildren) {
-final TreeNodeChildren candidate = (TreeNodeChildren) children;
-if (candidate.metadata == value) {
-return candidate;
-}
+if (children == null || ((TreeNodeChildren) children).metadata != 
value) {
+children = new TreeNodeChildren(this, value,
+table.standard.getAccessor(new 
CacheKey(value.getClass(), baseType), true));
 }
-/*
- * At this point, we need to create a new collection. The property 
accessor shall
- * exist, otherwise the call to 'isLeaf()' above would have 
returned 'true'.
- */
-children = new TreeNodeChildren(this, value,
-table.standard.getAccessor(new 

[jira] [Assigned] (SIS-298) Simplification in MetadataTreeFormat output

2017-05-03 Thread Martin Desruisseaux (JIRA)

 [ 
https://issues.apache.org/jira/browse/SIS-298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Desruisseaux reassigned SIS-298:
---

Assignee: Martin Desruisseaux

> Simplification in MetadataTreeFormat output
> ---
>
> Key: SIS-298
> URL: https://issues.apache.org/jira/browse/SIS-298
> Project: Spatial Information Systems
>  Issue Type: Improvement
>  Components: Metadata
>Affects Versions: 0.3, 0.4, 0.5, 0.6, 0.7
>Reporter: Martin Desruisseaux
>Assignee: Martin Desruisseaux
>Priority: Minor
> Fix For: 0.8
>
>
> We could simplify and clarify a little bit the tree produced by the 
> {{MetadataTreeFormat}} by using two additional rules:
> h3. Use less lines in simple case
> If a property has the same name than the parent property that contains it, we 
> could write its value in that parent property. For example instead of:
> {noformat}
> Citation
>  └─Date
> ├─Date 2012/01/01
> └─Date type …… Creation
> {noformat}
> We could simplify as:
> {noformat}
> Citation
>  └─Date……… 2012/01/01
> └─Date type …… Creation
> {noformat}
> h3. Tell the sub-type
> If a property has the same name than the value type, and if that value type 
> has sub-type, we could format the actual value sub-type in the tree. For 
> example {{Citation}} as a property named {{party}} of type {{Party}} 
> (ignoring multi-occurrences). But {{Party}} has two sub-types: {{Individual}} 
> and {{Organisation}}. So instead of:
> {noformat}
> Citation
>  └─Cited responsible party
> └─Party
>└─Name  Jon Smith
> {noformat}
> It would be helpful to format:
> {noformat}
> Citation
>  └─Cited responsible party
> └─Individual
>└─Name  Jon Smith
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)