public static void loadFromCache(AbstractBranchCacheMessage message, Collection<Branch> types) throws OseeCoreException { for (Branch br : types) { Integer branchId = br.getId(); message .getBranchRows() .add( new BranchRow( br.getId(), br.getGuid(), br.getName(), br.getBranchType(), br.getBranchState(), br.getArchiveState(), br.getStorageState())); if (br.hasParentBranch()) { message.getChildToParent().put(branchId, br.getParentBranch().getId()); } addTxRecord(message.getBranchToBaseTx(), branchId, br.getBaseTransaction()); addTxRecord(message.getBranchToSourceTx(), branchId, br.getSourceTransaction()); addAssocArtifact(message.getBranchToAssocArt(), branchId, br.getAssociatedArtifactId()); if (br.getBranchType().isMergeBranch()) { addMergeBranches(message.getMergeBranches(), (MergeBranch) br); } } }
public static Image getImage(Branch branch) { Image image = null; BranchType branchType = branch.getBranchType(); switch (branchType) { case SYSTEM_ROOT: image = ImageManager.getImage(FrameworkImage.BRANCH_SYSTEM_ROOT); break; case BASELINE: image = ImageManager.getImage(FrameworkImage.BRANCH_BASELINE); break; case WORKING: image = ImageManager.getImage(FrameworkImage.BRANCH_WORKING); break; case MERGE: image = ImageManager.getImage(FrameworkImage.BRANCH_MERGE); break; } return image; }
@Override protected ReadableBranch innerCall() throws Exception { Conditions.checkNotNull(branchToken, "branch"); Conditions.checkNotNull(branchType, "branchType"); Branch branch = cache.get(branchToken); Conditions.checkNotNull(branch, "branch"); BranchType original = branch.getBranchType(); try { branch.setBranchType(branchType); cache.storeItems(branch); } catch (Exception ex) { branch.setBranchType(original); throw ex; } finally { // TODO Event ? } return branch; }