Skip to content

Instantly share code, notes, and snippets.

@mikesname
Created September 5, 2012 11:57
Show Gist options
  • Save mikesname/3635588 to your computer and use it in GitHub Desktop.
Save mikesname/3635588 to your computer and use it in GitHub Desktop.
Create DocumentaryUnit with Repository and User params...
// Create a doc unit with a repository and a user...
// Glosses over lots of potential errors!
public void createDocumentaryUnit(Long repositoryId, Long userId,
Map<String, Object> data) throws ValidationError,
DeserializationError, PermissionDenied {
// Load the repository this collection will be part of...
Agent repo = graph.getVertex(repositoryId, Agent.class);
// Create a generic view class, which handles *generic* CRUD with
// permissions checking etc
Views<DocumentaryUnit> docview = new Views<DocumentaryUnit>(graph,
DocumentaryUnit.class);
// Obtain a documentary unit...
DocumentaryUnit unit = docview.create(data, userId);
// add the unit to the collection (creates a "holds" relationship)
repo.addCollection(unit);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment