@Test public void testCopyArtifact() throws OseeCoreException { String guid = GUID.create(); ArtifactData data = Mockito.mock(ArtifactData.class); VersionData version = Mockito.mock(VersionData.class); when(data.getVersion()).thenReturn(version); when(version.getBranchId()).thenReturn(111L); Artifact sourceArtifact = Mockito.spy(new ArtifactImpl(null, data, null, provider)); when(data.getGuid()).thenReturn(guid); List<? extends IAttributeType> copyTypes = Arrays.asList(CoreAttributeTypes.Active, CoreAttributeTypes.Name); when(sourceArtifact.getExistingAttributeTypes()).thenAnswer(answerValue(copyTypes)); when(artifact2.getOrcsData()).thenReturn(data); when(data.isUseBackingData()).thenReturn(false); when(txData.isCommitInProgress()).thenReturn(false); when(txData.getTxState()).thenReturn(TxState.NEW_TX); when(txData.getWriteable(sourceArtifact)).thenReturn(null); when(artifactFactory.copyArtifact(session, sourceArtifact, copyTypes, branch)) .thenReturn(artifact2); when(proxyManager.asExternalArtifact(session, artifact2)).thenReturn(readable2); ArtifactReadable actual = txDataManager.copyArtifact(txData, branch, sourceArtifact); verify(txData).getWriteable(sourceArtifact); verify(artifactFactory).copyArtifact(session, sourceArtifact, copyTypes, branch); assertEquals(readable2, actual); }
private void updateDataForIntroduce(IOseeBranch destination, OrcsData data) throws OseeCoreException { VersionData version = data.getVersion(); version.setBranchId(destination.getUuid()); version.setHistorical(false); version.setTransactionId(RelationalConstants.TRANSACTION_SENTINEL); // do not clear gammaId for introduce case so we reuse the same version }
private void updateGamma(OrcsData data) throws OseeCoreException { VersionData version = data.getVersion(); long gammaId = version.getGammaId(); if (RelationalConstants.GAMMA_SENTINEL == gammaId || isGammaCreationAllowed(data)) { long newGamma = idFactory.getNextGammaId(); version.setGammaId(newGamma); } }
@Override public AttributeData create(ArtifactData parent, IAttributeType attributeType) throws OseeCoreException { VersionData version = objectFactory.createDefaultVersionData(); version.setBranchId(parent.getVersion().getBranchId()); ModificationType modType = RelationalConstants.DEFAULT_MODIFICATION_TYPE; Integer attributeid = RelationalConstants.DEFAULT_ITEM_ID; return objectFactory.createAttributeData( version, attributeid, attributeType, modType, parent.getLocalId()); }
@Override public RelationData createRelationData( IRelationType relationType, IOseeBranch branch, HasLocalId<Integer> aArt, HasLocalId<Integer> bArt, String rationale) throws OseeCoreException { VersionData version = objectFactory.createDefaultVersionData(); version.setBranchId(branch.getUuid()); ModificationType modType = RelationalConstants.DEFAULT_MODIFICATION_TYPE; Integer relationId = RelationalConstants.DEFAULT_ITEM_ID; return objectFactory.createRelationData( version, relationId, relationType, modType, aArt.getLocalId(), bArt.getLocalId(), rationale); }
private void addTxs(SqlOrderEnum key, OrcsData orcsData) { VersionData data = orcsData.getVersion(); ModificationType modType = orcsData.getModType(); addRow( SqlOrderEnum.TXS, data.getTransactionId(), data.getGammaId(), modType.getValue(), TxChange.getCurrent(modType).getValue(), data.getBranchId()); if (key.hasTxNotCurrentQuery()) { ArtifactJoinQuery join = txNotCurrentsJoin.get(key); if (join == null) { join = createJoin(); txNotCurrentsJoin.put(key, join); } join.add(orcsData.getLocalId(), data.getBranchId(), RelationalConstants.TRANSACTION_SENTINEL); } }
@Override public ArtifactData create(IOseeBranch branch, IArtifactType token, String guid, long uuid) throws OseeCoreException { Conditions.checkNotNull(branch, "branch"); Conditions.checkExpressionFailOnTrue( artifactCache.isAbstract(token), "Cannot create an instance of abstract type [%s]", token); String guidToSet = idFactory.getUniqueGuid(guid); Conditions.checkExpressionFailOnTrue( !GUID.isValid(guidToSet), "Invalid guid [%s] during artifact creation [type: %s]", guidToSet, token); VersionData version = objectFactory.createDefaultVersionData(); version.setBranchId(branch.getUuid()); ModificationType modType = RelationalConstants.DEFAULT_MODIFICATION_TYPE; ArtifactData artifactData = objectFactory.createArtifactData(version, (int) uuid, token, modType, guidToSet); return artifactData; }
@Override public void onRow(String... row) { // ArtIdA,ArtIdB,BranchId,GammaId,ModType,Rationale,RelationId,RelationTypeId if (row.length != 9) { Assert.assertTrue("Data file is not formatted correctly", false); } VersionData version = Mockito.mock(VersionData.class); version.setBranchId(Integer.parseInt(row[3])); version.setGammaId(Integer.parseInt(row[4])); RelationData relationRow = Mockito.mock(RelationData.class); Mockito.when(relationRow.getParentId()).thenReturn(Integer.parseInt(row[0])); Mockito.when(relationRow.getArtIdA()).thenReturn(Integer.parseInt(row[1])); Mockito.when(relationRow.getArtIdB()).thenReturn(Integer.parseInt(row[2])); Mockito.when(relationRow.getModType()).thenReturn(ModificationType.valueOf(row[5])); Mockito.when(relationRow.getRationale()).thenReturn(row[6]); Mockito.when(relationRow.getLocalId()).thenReturn(Integer.parseInt(row[7])); Mockito.when(relationRow.getTypeUuid()).thenReturn(Long.parseLong(row[8])); Mockito.when(relationRow.getVersion()).thenReturn(version); data.add(relationRow); }
private void updateDataForCopy(IOseeBranch destination, OrcsData data) throws OseeCoreException { VersionData version = data.getVersion(); version.setBranchId(destination.getUuid()); version.setTransactionId(RelationalConstants.TRANSACTION_SENTINEL); version.setStripeId(RelationalConstants.TRANSACTION_SENTINEL); version.setHistorical(false); version.setGammaId(RelationalConstants.GAMMA_SENTINEL); data.setModType(ModificationType.NEW); }