// Create a composite request ...
Request composite = CompositeRequest.with(requests);
Graph.this.execute(composite);
Map<Name, Property> results = new HashMap<Name, Property>();
for (ReadPropertyRequest request : requests) {
Property property = request.getProperty();
results.put(property.getName(), property);
}
return results;
}
public Map<Location, Map<Name, Property>> on( Collection<Location> locations ) {
CheckArg.isNotNull(locations, "locations");
final List<ReadPropertyRequest> requests = new LinkedList<ReadPropertyRequest>();
String workspace = getCurrentWorkspaceName();
for (Location location : locations) {
if (location == null) continue;
for (Name propertyName : names) {
if (propertyName == null) continue;
requests.add(new ReadPropertyRequest(location, workspace, propertyName));
}
}
return execute(requests);
}
/**
* {@inheritDoc}
*
* @see org.jboss.dna.graph.Graph.OnMultiple#on(org.jboss.dna.graph.Location, org.jboss.dna.graph.Location[])
*/
public Map<Location, Map<Name, Property>> on( Location first,
Location... additional ) {
CheckArg.isNotNull(first, "first");
final List<ReadPropertyRequest> requests = new LinkedList<ReadPropertyRequest>();
String workspace = getCurrentWorkspaceName();
for (Location location : additional) {
if (location == null) continue;
for (Name propertyName : names) {
if (propertyName == null) continue;
requests.add(new ReadPropertyRequest(first, workspace, propertyName));
requests.add(new ReadPropertyRequest(location, workspace, propertyName));
}
}
return execute(requests);
}
/**
* {@inheritDoc}
*
* @see org.jboss.dna.graph.Graph.OnMultiple#on(org.jboss.dna.graph.property.Path,
* org.jboss.dna.graph.property.Path[])
*/
public Map<Location, Map<Name, Property>> on( Path first,
Path... additional ) {
CheckArg.isNotNull(first, "first");
List<Location> locations = new LinkedList<Location>();
locations.add(Location.create(first));
for (Path path : additional) {
if (path != null) locations.add(Location.create(path));
}
return on(locations);
}
/**
* {@inheritDoc}
*
* @see org.jboss.dna.graph.Graph.OnMultiple#on(java.lang.String, java.lang.String[])
*/
public Map<Location, Map<Name, Property>> on( String first,
String... additional ) {
CheckArg.isNotNull(first, "first");
List<Location> locations = new LinkedList<Location>();
locations.add(Location.create(createPath(first)));
for (String path : additional) {
if (path != null) locations.add(Location.create(createPath(path)));
}
return on(locations);
}
/**
* {@inheritDoc}
*
* @see org.jboss.dna.graph.Graph.OnMultiple#on(java.util.UUID, java.util.UUID[])
*/
public Map<Location, Map<Name, Property>> on( UUID first,
UUID... additional ) {
CheckArg.isNotNull(first, "first");
List<Location> locations = new LinkedList<Location>();
locations.add(Location.create(first));
for (UUID uuid : additional) {
if (uuid != null) locations.add(Location.create(uuid));
}
return on(locations);
}
protected Map<Location, Map<Name, Property>> execute( List<ReadPropertyRequest> requests ) {
// Create a composite request ...
Request composite = CompositeRequest.with(requests);
Graph.this.execute(composite);
Map<Location, Map<Name, Property>> results = new HashMap<Location, Map<Name, Property>>();
for (ReadPropertyRequest request : requests) {
Property property = request.getProperty();
// property was requested but doesn't exist
if (property == null) continue;
Location location = request.getActualLocationOfNode();
Map<Name, Property> properties = results.get(location);
if (properties == null) {
properties = new HashMap<Name, Property>();
results.put(location, properties);
}
properties.put(property.getName(), property);
}
return results;
}
};
}