Skip to content

Commit

Permalink
Merge pull request #145 from fvillalba/with-asset-node-interface
Browse files Browse the repository at this point in the history
Overhaul of site plan service implementation of Nav Service.
  • Loading branch information
Tony Field committed Mar 13, 2017
2 parents b231c90 + 10f26e6 commit fef3c6a
Show file tree
Hide file tree
Showing 19 changed files with 924 additions and 595 deletions.
2 changes: 1 addition & 1 deletion gsf-build-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>tools.gsf</groupId>
<artifactId>gsf-build-tools</artifactId>
<version>12.0.1-SNAPSHOT</version>
<version>12.0.1</version>
<packaging>jar</packaging>
<name>Sites GSF: Build Tools</name>
<inceptionYear>2012</inceptionYear>
Expand Down
2 changes: 1 addition & 1 deletion gsf-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>tools.gsf</groupId>
<artifactId>gsf-parent</artifactId>
<version>12.0.1-SNAPSHOT</version>
<version>12.0.1</version>
</parent>
<artifactId>gsf-core</artifactId>
<packaging>jar</packaging>
Expand Down
49 changes: 6 additions & 43 deletions gsf-core/src/main/java/tools/gsf/navigation/AssetNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,53 +15,16 @@
*/
package tools.gsf.navigation;

import com.fatwire.assetapi.common.AssetAccessException;
import com.fatwire.assetapi.data.AssetData;
import com.fatwire.assetapi.data.AssetId;
import com.fatwire.assetapi.data.AttributeData;
import com.fatwire.assetapi.data.BlobObject;
import com.fatwire.assetapi.def.AssetTypeDef;
import com.fatwire.assetapi.def.AttributeTypeEnum;
import com.fatwire.mda.Dimension;

import java.util.Date;
import java.util.List;

/**
* Simple node, representing an asset, that can be populated with asset data. Not all attributes
* of the asset are necessarily loaded into this node. Many convenience methods exist for retrieving
* node attribute data.
* @author Tony Field
* @since 2016-07-04.
* Simple node, representing an asset, that can be populated with asset data.
* It is up to the implementation to decide what data to expose and how.
* @author Freddy Villalba
* @since 2017-03-02.
*/
public interface AssetNode extends Node<AssetNode> {
public interface AssetNode<A extends AssetNode<A>> extends Node<A> {

AssetId getId();

AssetId asAssetId(String name);
BlobObject asBlob(String name);
BlobObject.BlobAddress asBlobAddress(String name);
Date asDate(String name);
Double asDouble(String name);
Float asFloat(String name);
Integer asInt(String name);
List<?> asList(String name);
Long asLong(String name);
String asString(String name);
AssetTypeDef getAssetTypeDef();
AssetId getAssociatedAsset(String name);
List<AssetId> getAssociatedAssets(String name);
Object getAttribute(String name);
AssetData getAssetData();
AttributeData getAttributeData(String name, boolean meta);
List<String> getAttributeNames();
List<AssetId> getImmediateParents(String name) throws AssetAccessException;
Dimension getLocale();
Object getMetaAttribute(String name);
List<String> getMetaAttributeNames();
List<AssetId> getParents() throws AssetAccessException;
String getSubtype();
AttributeTypeEnum getAttributeType(String name);
boolean isAttribute(String name);
boolean isSingleValued(String name);

}
65 changes: 65 additions & 0 deletions gsf-core/src/main/java/tools/gsf/navigation/ConfigurableNode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright 2016 Function1. All Rights Reserved.
*
* Licensed 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.
*/
package tools.gsf.navigation;

/**
* @author Freddy Villalba
*
*
*/
public interface ConfigurableNode<T extends Node<T>> {


/**
* Add a child at the end of this node's list of children.
*
* If children must be ordered in any particular way, it's the caller's responsibility to add them in the right order.
*
* This method must be invoked BEFORE setParent. Calling it AFTER setParent will throw a runtime exception.
*
* @param node
*/
void addChild(T node);

/**
* Can only be called once per instance. Otherwise, a runtime exception will be thrown.
* @param node
*/
void setParent(T node);

/**
* Breaks the relationship between this node and all of its children, meaning:
*
* - This node is not the parent of any of its children anymore.
* - The removed nodes are not this node's children anymore.
*
*/
void removeChildren();

/**
* Breaks the relationship between this node and the specified child, meaning:
*
* - This node is not the parent of the specified child anymore.
* - The removed node is not this node's child anymore.
*
* The method returns true if the specified child was removed, false otherwise.
*
* @param child The child node we want to remove
* @return true if the node was removed, false otherwise
*/
boolean removeChild(T child);

}

This file was deleted.

4 changes: 1 addition & 3 deletions gsf-core/src/main/java/tools/gsf/navigation/NavService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package tools.gsf.navigation;

import com.fatwire.assetapi.data.AssetId;

import java.util.List;

/**
Expand All @@ -33,7 +31,7 @@
* @author Tony Field
* @since 2016-06-28
*/
public interface NavService<N extends Node, S, P> {
public interface NavService<N extends Node<N>, S, P> {

/**
* Returns the nodes corresponding to the nav structure specified.
Expand Down
12 changes: 6 additions & 6 deletions gsf-core/src/main/java/tools/gsf/navigation/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@
import java.util.List;

/**
* Navigation structure node. Knows how to return parent nodes, child nodes, sibling nodes, and the id of the object
* represented by this node.
* Navigation structure node. Knows how to return parent nodes, child nodes and sibling nodes.
*
* Designed to be extended to support more sophisticated node types.
*
* @author Tony Field
* @since 2016-07-02.
*/
public interface Node<NODE extends Node> extends Serializable {
public interface Node<N extends Node<N>> extends Serializable {

/**
* Get the parent node
* @return parent node
*/
NODE getParent();
N getParent();

/**
* Get the siblings of this node. All siblings are returned in ranked order, including this node.
* @return sibling nodes
*/
List<NODE> getSiblings();
List<N> getSiblings();

/**
* Return this node's children, if any, in ranked order
* @return this node's children, never null.
*/
List<NODE> getChildren();
List<N> getChildren();

}
Loading

0 comments on commit fef3c6a

Please sign in to comment.