use of org.sagebionetworks.repo.model.NodeRevisionBackup in project Synapse-Repository-Services by Sage-Bionetworks.
the class SerializationUseCases method createV1DatasetRevision.
public static NodeRevisionBackup createV1DatasetRevision() {
// Create a dataset with data
Study ds = createDatasetWithAllFields();
// Get the annotations for this object
NamedAnnotations annos = createAnnotationsV1(ds);
// now create a revision for this node
NodeRevisionBackup rev = createRevisionV1(ds, annos);
rev.setXmlVersion(NodeRevisionBackup.XML_V_1);
return rev;
}
use of org.sagebionetworks.repo.model.NodeRevisionBackup in project Synapse-Repository-Services by Sage-Bionetworks.
the class SerializationUseCases method main.
public static void main(String[] args) {
// project v0
NodeRevisionBackup rev = createV0ProjectRevision();
StringWriter writer = new StringWriter();
NodeSerializerUtil.writeNodeRevision(rev, writer);
System.out.println("project v0 xml");
System.out.println(writer.toString());
// dataset v0
rev = createV0DatasetRevision();
writer = new StringWriter();
NodeSerializerUtil.writeNodeRevision(rev, writer);
System.out.println("dataset v0 xml");
System.out.println(writer.toString());
// project v1
rev = createV1ProjectRevision();
writer = new StringWriter();
NodeSerializerUtil.writeNodeRevision(rev, writer);
System.out.println("project v1 xml");
System.out.println(writer.toString());
// project v1
rev = createV1DatasetRevision();
writer = new StringWriter();
NodeSerializerUtil.writeNodeRevision(rev, writer);
System.out.println("dataset v1 xml");
System.out.println(writer.toString());
// step v1
rev = createV1StepRevision();
writer = new StringWriter();
NodeSerializerUtil.writeNodeRevision(rev, writer);
System.out.println("step v1 xml");
System.out.println(writer.toString());
}
use of org.sagebionetworks.repo.model.NodeRevisionBackup in project Synapse-Repository-Services by Sage-Bionetworks.
the class SerializationUseCases method createV1StepRevision.
/**
* This will create a Step revision with references
*
* This is a little more complicated now with references. TODO think about
* how to factor this more cleanly. The problem is that in the real
* codebase, we don't go from Node -> NodeRevisionBackup, we go from Entity ->
* Node -> JDORevision -> NodeRevisionBackup. We wind up writing a bunch of
* artificial code here instead of testing the real code path.
*
* @return
*/
public static NodeRevisionBackup createV1StepRevision() {
// Create a Step
Step step = createStepWithReferences();
/**
**********
* This code is lifted from EntityManagerImpl.createEntity.
*/
Node node = NodeTranslationUtils.createFromEntity(step);
// Set the type for this object
node.setNodeType(EntityType.getNodeTypeForClass(step.getClass()).toString());
NamedAnnotations named = new NamedAnnotations();
// Now add all of the annotations and references from the step
NodeTranslationUtils.updateNodeSecondaryFieldsFromObject(step, named.getPrimaryAnnotations(), node.getReferences());
/**
**********
*/
// Add some annotations
Annotations additionalAnnos = named.getAdditionalAnnotations();
addAdditionalAnnotations(additionalAnnos);
// Now create a revision for this node
NodeRevisionBackup rev = new NodeRevisionBackup();
rev.setRevisionNumber(1l);
rev.setNodeId(node.getId());
rev.setLabel("The first version of this object");
rev.setComment("I have no comment at this time");
rev.setNamedAnnotations(named);
rev.setReferences(node.getReferences());
rev.setXmlVersion(NodeRevisionBackup.XML_V_1);
return rev;
}
use of org.sagebionetworks.repo.model.NodeRevisionBackup in project Synapse-Repository-Services by Sage-Bionetworks.
the class SerializationUseCases method createRevisionV1.
public static <T extends Entity> NodeRevisionBackup createRevisionV1(T ds, NamedAnnotations annos) {
NodeRevisionBackup rev = createBasicRev(ds);
rev.setNamedAnnotations(annos);
return rev;
}
use of org.sagebionetworks.repo.model.NodeRevisionBackup in project Synapse-Repository-Services by Sage-Bionetworks.
the class SerializationUseCases method createRevisionV0.
public static <T extends Entity> NodeRevisionBackup createRevisionV0(T ds, Annotations annos) {
NodeRevisionBackup rev = createBasicRev(ds);
rev.setAnnotations(annos);
return rev;
}
Aggregations