You can specify relationships between resources in the
repository. There are three kinds of relationships:
Dependence: a relationship in which a resource
depends on other resources, meaning that all related resources are
needed in the repository.
Membership (file system): a relationship in which
a resource is located within a given folder.
Custom: a relationship you specify between resources.
For example, if one resource has been deprecated and another resource
introduced into the repository, you could specify your own replacement
relationship.
You can create
your own custom relationships. For example, if you store an HTML file
in the repository and it uses an image, you could specify a custom relationship
to relate the HTML file with the image (since normally only XML
files are associated with images using a repository-defined dependence
relationship). Another example of a custom relationship would be
if you wanted to build a different view of the repository with a
cyclical graph structure instead of a tree structure. You could
define a circular graph along with a viewer to traverse those relationships.
Finally, you could indicate that a resource replaces another resource
even though the two resources are completely different. In that
case you could define a relationship type outside of the reserved
range and create a relationship between those two resources. Your
application would be the only client that could detect and process
the relationship, and it could be used to conduct searches on that
relationship.
You can programmatically specify relationships between resources
by using the Repository service Java API or web service API.
Summary of stepsTo specify a relationship between two resources, follow
these steps:
Include project files.
Create a Repository service client.
Specify the URIs of the resources to be related.
Create the relationship.
Include project filesInclude the necessary files in your development
project. If you are creating a client application using Java, include
the necessary JAR files. If you are using web services, include
the proxy files.
Create the service clientBefore you can programmatically read
a resource, you must establish a connection and provide credentials.
This is accomplished by creating a service client.
Specify the URIs of the resources to be relatedCreate strings
containing the URIs of the resource to be related. The syntax includes
forward slashes, as in this example: "/path/resource".
Create the relationshipInvoke the Repository service method
to create and specify the type of relationship.
Create relationship resources using the Java APICreate relationship resources by using the Repository service
Java API, perform the following tasks:
Include project files
Include client JAR files
in your Java project’s class path.
Create the service client
Create a ResourceRepositoryClient object
by using its constructor and passing a ServiceClientFactory object
that contains connection properties.
Specify the URIs of the resources to be related
Specify
the URIs of the resources to be related. In this case, because the resources
are named testResource1 and testResource2 and
are located in the folder named testFolder, their
URIs are "/testFolder/testResource1" and "/testFolder/testResource2".
The URIs are stored as a java.lang.String objects.
In this example, the resources are first written to the repository,
and their URIs are retrieved. For more information about writing
a resource, see Writing Resources.
Create the relationship
Invoke the ResourceRepositoryClient object’s createRelationship method
and pass in the following parameters:
The URI of the
source resource.
The URI of the target resource.
The type of relationship, which is one of the static constants
in the com.adobe.repository.infomodel.bean.Relation class.
In this example, a dependence relationship is established by specifying
the value Relation.TYPE_DEPENDANT_OF.
A boolean value indicating whether the target
resource is automatically updated to the com.adobe.repository.infomodel.Id-based identifier
of the new head resource. In this example, because of the dependence
relationship, the value true is specified.
You
can also retrieve a list of related resources for a given resource
by invoking the ResourceRepositoryClient object’s getRelated method
and passing in the following parameters:
The URI of
the resource for which to retrieve related resources. In this example,
the source resource ("/testFolder/testResource1")
is specified.
A boolean value indicating whether the specified
resource is the source resource in the relationship. In this example,
the value true is specified because this is the
case.
The relationship type, which is one of the static constants
in the Relation class. In this example, a dependence
relationship is specified by using the same value used earlier: Relation.TYPE_DEPENDANT_OF.
The getRelated method
returns a java.util.List of Resource objects
through which you can iterate to retrieve each of the related resources, casting
the objects contained in the List to Resource as
you do so. In this example, testResource2 is expected
to be in the list of returned resources.
Create relationship resources using the web service APICreate relationship resources by using the Repository API
(web service):
Include project files
Create the service client
Using the Microsoft .NET
client assembly, create a RepositoryServiceService object
by invoking its default constructor. Set its Credentials property
using a System.Net.NetworkCredential object containing
the user name and password.
Specify the URIs of the resources to be related
Specify
the URIs of the resources to be related. In this case, because the resources
are named testResource1 and testResource2 and
are located in the folder named testFolder, their
URIs are "/testFolder/testResource1" and "/testFolder/testResource2".
When using a language compliant with the Microsoft .NET Framework
(for example, C#), the URIs are stored as a System.String objects.
In this example, the resources are first written to the repository,
and their URIs are retrieved. For more information about writing
a resource, see Writing Resources.
Create the relationship
Invoke the RepositoryServiceService object’s createRelationship method
and pass in the following parameters:
The URI of the
source resource.
The URI of the target resource.
The type of relationship. In this example, a dependence relationship
is established by specifying the value 3.
A boolean value indicating whether the relationship
type was specified. In this example, the value true is
specified.
A boolean value indicating whether the target
resource is automatically updated to the Id-based
identifier of the new head resource. In this example, because of
the dependence relationship, the value true is specified.
A boolean value indicating whether the target
head was specified. In this example, the value true is
specified.
Pass null for the last parameter.
You
can also retrieve a list of related resources for a given resource
by invoking the RepositoryServiceService object’s getRelated method
and passing in the following parameters:
The URI of
the resource for which to retrieve related resources. In this example,
the source resource ("/testFolder/testResource1")
is specified.
A boolean value indicating whether the specified
resource is the source resource in the relationship. In this example,
the value true is specified because this is the
case.
A boolean value indicating whether the source
resource was specified. In this example, the value true is
provided.
An array of integers containing the relationship types. In
this example, a dependence relationship is specified by using the
same value in the array as was used earlier: 3.
Pass null for the remaining two parameters.
The getRelated method
returns an array of objects that can be cast to Resource objects
through which you can iterate to retrieve each of the related resources.
In this example, testResource2 is expected to be
in the list of returned resources.
|
|
|