Search in sources :

Example 16 with NodeRevisionBackup

use of org.sagebionetworks.repo.model.NodeRevisionBackup in project Synapse-Repository-Services by Sage-Bionetworks.

the class GenericMigratorTest method before.

@Before
public void before() {
    // mockType = Mockito.mock(EntityType.class);
    genericMigrator = new GenericMigrator();
    toMigrate = new NodeRevisionBackup();
}
Also used : NodeRevisionBackup(org.sagebionetworks.repo.model.NodeRevisionBackup) Before(org.junit.Before)

Example 17 with NodeRevisionBackup

use of org.sagebionetworks.repo.model.NodeRevisionBackup in project Synapse-Repository-Services by Sage-Bionetworks.

the class DataTypeMigratorTest method before.

@Before
public void before() {
    // mockType = Mockito.mock(EntityType.class);
    dataTypeMigrator = new DataTypeMigrator();
    toMigrate = new NodeRevisionBackup();
}
Also used : NodeRevisionBackup(org.sagebionetworks.repo.model.NodeRevisionBackup) Before(org.junit.Before)

Example 18 with NodeRevisionBackup

use of org.sagebionetworks.repo.model.NodeRevisionBackup in project Synapse-Repository-Services by Sage-Bionetworks.

the class NodeBackupManagerImplAutowireTest method testPLFM_987Part2.

@Test
public void testPLFM_987Part2() throws Exception {
    // First get the current node backup
    List<NodeRevisionBackup> startingRevs = new ArrayList<NodeRevisionBackup>();
    NodeBackup startingBackup = backupManager.getNode(newNodeId);
    // Get all of the revisions
    for (Long revNumer : startingBackup.getRevisions()) {
        NodeRevisionBackup rev = backupManager.getNodeRevision(newNodeId, revNumer);
        startingRevs.add(rev);
    }
    // Now create a new version of the entity
    Node updatedNode = nodeManager.get(nonAdminUser, newNodeId);
    // Set a new version label
    updatedNode.setVersionLabel("newLable");
    nodeManager.update(nonAdminUser, updatedNode, null, true);
    // Now get the backup again.
    List<NodeRevisionBackup> updatedRevs = new ArrayList<NodeRevisionBackup>();
    NodeBackup updatedNodeBackup = backupManager.getNode(newNodeId);
    // Get all of the revisions
    for (Long revNumer : updatedNodeBackup.getRevisions()) {
        NodeRevisionBackup rev = backupManager.getNodeRevision(newNodeId, revNumer);
        updatedRevs.add(rev);
    }
    // Now start clean
    nodeManager.delete(nonAdminUser, newNodeId);
    // Now apply the first restore.
    backupManager.createOrUpdateNodeWithRevisions(startingBackup, startingRevs);
    // Create multiple versions that should get replaced.
    updatedNode = nodeManager.get(nonAdminUser, newNodeId);
    // Set a new version label
    updatedNode.setVersionLabel("newLabel2");
    nodeManager.update(nonAdminUser, updatedNode, null, true);
    updatedNode = nodeManager.get(nonAdminUser, newNodeId);
    // Set a new version label
    updatedNode.setVersionLabel("newLabel3");
    nodeManager.update(nonAdminUser, updatedNode, null, true);
    updatedNode = nodeManager.get(nonAdminUser, newNodeId);
    // Set a new version label
    updatedNode.setVersionLabel("newLabel4");
    nodeManager.update(nonAdminUser, updatedNode, null, true);
    // Now update using the new object
    backupManager.createOrUpdateNodeWithRevisions(updatedNodeBackup, updatedRevs);
    // The revisions should match the replaced revisions
    NodeBackup cloneBackup = backupManager.getNode(newNodeId);
    // Get all of the revisions
    List<NodeRevisionBackup> cloneRevisions = new ArrayList<NodeRevisionBackup>();
    for (Long revNumer : cloneBackup.getRevisions()) {
        NodeRevisionBackup rev = backupManager.getNodeRevision(newNodeId, revNumer);
        cloneRevisions.add(rev);
    }
    // they should match
    // Make sure they are in the same order before comparing them.
    Collections.sort(updatedRevs, comp);
    Collections.sort(cloneRevisions, comp);
    assertEquals(updatedRevs, cloneRevisions);
}
Also used : Node(org.sagebionetworks.repo.model.Node) ArrayList(java.util.ArrayList) NodeBackup(org.sagebionetworks.repo.model.NodeBackup) NodeRevisionBackup(org.sagebionetworks.repo.model.NodeRevisionBackup) Test(org.junit.Test)

Example 19 with NodeRevisionBackup

use of org.sagebionetworks.repo.model.NodeRevisionBackup in project Synapse-Repository-Services by Sage-Bionetworks.

the class NodeBackupStub method getNodeRevisionIds.

public List<Long> getNodeRevisionIds(String id) {
    TreeNodeBackup nn = getNodeNode(id);
    // Build up the list of children
    List<Long> rervisions = new ArrayList<Long>();
    for (NodeRevisionBackup rev : nn.getRevisions()) {
        rervisions.add(rev.getRevisionNumber());
    }
    return rervisions;
}
Also used : ArrayList(java.util.ArrayList) NodeRevisionBackup(org.sagebionetworks.repo.model.NodeRevisionBackup)

Example 20 with NodeRevisionBackup

use of org.sagebionetworks.repo.model.NodeRevisionBackup in project Synapse-Repository-Services by Sage-Bionetworks.

the class NodeBackupStub method getNodeRevision.

@Override
public NodeRevisionBackup getNodeRevision(String nodeId, Long revId) {
    String revKey = createKeyForLongs(nodeId, revId);
    NodeRevisionBackup rev = revisionIdMap.get(revKey);
    if (rev != null) {
        rev.setXmlVersion(NodeRevisionBackup.CURRENT_XML_VERSION);
    }
    return rev;
}
Also used : NodeRevisionBackup(org.sagebionetworks.repo.model.NodeRevisionBackup)

Aggregations

NodeRevisionBackup (org.sagebionetworks.repo.model.NodeRevisionBackup)42 Test (org.junit.Test)16 NamedAnnotations (org.sagebionetworks.repo.model.NamedAnnotations)12 Node (org.sagebionetworks.repo.model.Node)11 NodeBackup (org.sagebionetworks.repo.model.NodeBackup)9 Date (java.util.Date)7 Annotations (org.sagebionetworks.repo.model.Annotations)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)4 Set (java.util.Set)4 StringWriter (java.io.StringWriter)3 HashMap (java.util.HashMap)3 Before (org.junit.Before)3 AccessControlList (org.sagebionetworks.repo.model.AccessControlList)3 EntityPath (org.sagebionetworks.repo.model.EntityPath)3 EntityType (org.sagebionetworks.repo.model.EntityType)3 IOException (java.io.IOException)2 StringReader (java.io.StringReader)2 ZipEntry (java.util.zip.ZipEntry)2 Project (org.sagebionetworks.repo.model.Project)2