wt.epm.familytable
Class FamilyDomainHelper

java.lang.Object
  extended bywt.epm.familytable.FamilyDomainHelper

public class FamilyDomainHelper
extends Object


Nested Class Summary
private static class FamilyDomainHelper.DomainInfo
          DomainInfo holds the old and new domain.
 
Field Summary
private static Object nothing
           
 
Constructor Summary
FamilyDomainHelper()
           
 
Method Summary
static WTKeyedMap createDomainInfo(WTCollection documents)
          Creates a DomainInfo object for each document.
private static WTKeyedMap createDomainInfo(WTCollection documents, WTKeyedMap domainByDocument)
          Creates a DomainInfo object for each document.
private static QuerySpec createFTQuery(WTCollection documents, boolean useMasterID)
          Returns a query spec which retrieves the family tables associated to iterations either w/the same master or on the same branch of the given documents.
static WTKeyedMap filterAndCreateDomainInfo(WTCollection documents, boolean isAllVersions)
          Given a list of documents, creates a DomainInfo objects for each top generic document.
static AdminDomainRef findContainsDomain(Collection containedInLinks)
          Returns the domain of the "contains" documents in the given contained in links.
static AdminDomainRef findDomain(Collection documents)
          Given a list of family members, returns the domain of the member that is, a working copy Top Generic, a working copy Instance, a top Generic in a project, an instance in a project, or a top Generic in PDM.
static WTKeyedMap findDomain(WTKeyedMap indexByFT)
          Returns a WTKeyedMap whose keys are the input family tables and whose values are the corresponding AdminDomainRef.
private static EPMDocument getDocumentInProject(Collection documents)
          Given a list of documents, returns the top generic if it's in project.
private static Long getID(EPMDocument document, boolean useMasterID)
          Returns a Long object of either Branch ID or Master ID.
private static WTKeyedMap getTargetDomain(WTKeyedMap infoByDocuments, boolean useMasterID)
          Returns the family tables associated to the latest and the related document iterations.
private static EPMDocument getTopGeneric(Collection documents)
          Returns the top generic in the given list of documents.
static WTCollection getTopGenericDocuments(WTCollection objects)
          Given a list of objects, returns only the top generic documents.
private static EPMDocument getWorkingCopy(Collection documents)
          Given a list of documents, returns Top Generic working copy.
static boolean isSameDomain(AdminDomainRef domainX, AdminDomainRef domainY)
          Returns true if the domains passed in are the same.
protected static void processPostDomainChangeEvent(WTCollection domainAdministeredObjects, WTCollection domainAdminRefs)
          Updates the domain of the family table objects associated to the top generic whose domain is changed.
private static void removeNoPredecessor(WTCollection iterations)
          Remove the given objects w/no predecessors.
static void removeUnchangedDomain(WTKeyedMap infoByDocument)
          Remove objects whose domains are not changed.
protected static WTCollection saveDomain(WTKeyedMap familyTables)
          Sets the domain on the family tables and saves them.
static WTCollection setDomainAtCheckin(WTKeyedMap ftByMember, WTKeyedMap infoByChangedFolder, WTKeyedMap infoByMovedContainer)
          Updates the Domain of the family tables affected by the check in objects.
private static void setNewDomain(WTKeyedMap infoByDocument)
          Updates the new domain on DomainInfo with the document's current domain.
private static Map sortByID(WTKeyedMap byDocuments, boolean useMasterID)
          Sorts the objects by the documents' master ID or branch ID.
private static WTKeyedMap sortByValue(WTKeyedMap map)
          Returns a WTKeyedMap w/the reversed key and value.
private static WTKeyedMap toMap(WTCollection keys, WTCollection values)
          Makes a map out of the two collections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nothing

private static final Object nothing
Constructor Detail

FamilyDomainHelper

public FamilyDomainHelper()
Method Detail

setDomainAtCheckin

public static WTCollection setDomainAtCheckin(WTKeyedMap ftByMember,
                                              WTKeyedMap infoByChangedFolder,
                                              WTKeyedMap infoByMovedContainer)
                                       throws WTException
Updates the Domain of the family tables affected by the check in objects.

Parameters:
ftByMember - a set of members and their family tables.
infoByChangedFolder - a map whose keys are documents w/their folders changed and whose values are the documents' old and new domain.
infoByMovedContainer - a map whose keys are documents w/their containers moved and whose values are the documents' old and new domain.
Returns:
WTCollection a collection of family tables w/the updated domain.
Throws:
WTException

saveDomain

protected static WTCollection saveDomain(WTKeyedMap familyTables)
                                  throws WTException
Sets the domain on the family tables and saves them.

Parameters:
familyTables - a map whose keys are the family table and whose values are the domain to be set.
Returns:
WTCollection the family table object with the proper domain set.
Throws:
WTException

findDomain

public static WTKeyedMap findDomain(WTKeyedMap indexByFT)
                             throws WTException
Returns a WTKeyedMap whose keys are the input family tables and whose values are the corresponding AdminDomainRef. For how a domain is calculated, see findDomain(Collection). This method first looks into the input list of documents to find the domain. If the documents passed in do not carry the domain for the family table, queries all the members of the family members to find the right domain.

Parameters:
indexByFT - a map whose keys are the family tables and whose values are Collection of preferred family members.
Returns:
WTKeyedMap whose keys are the family tables and whose values are the corresponding domain to be set on family table.
Throws:
WTException

getDocumentInProject

private static EPMDocument getDocumentInProject(Collection documents)
                                         throws WTException
Given a list of documents, returns the top generic if it's in project. Otherwise, returns any instance in project. Returns null if no document is in project.

Throws:
WTException

getWorkingCopy

private static EPMDocument getWorkingCopy(Collection documents)
                                   throws WTException
Given a list of documents, returns Top Generic working copy. Otherwise, returns Instance working copy. Returns null if no document is a working copy.

Throws:
WTException

getTopGeneric

private static EPMDocument getTopGeneric(Collection documents)
Returns the top generic in the given list of documents.


findDomain

public static AdminDomainRef findDomain(Collection documents)
                                 throws WTException
Given a list of family members, returns the domain of the member that is, a working copy Top Generic, a working copy Instance, a top Generic in a project, an instance in a project, or a top Generic in PDM.

Throws:
WTException

findContainsDomain

public static AdminDomainRef findContainsDomain(Collection containedInLinks)
                                         throws WTException
Returns the domain of the "contains" documents in the given contained in links. See findDomain for details.

Throws:
WTException

toMap

private static WTKeyedMap toMap(WTCollection keys,
                                WTCollection values)
                         throws WTException
Makes a map out of the two collections. The size of the two collections must be the same.

Throws:
WTException

processPostDomainChangeEvent

protected static void processPostDomainChangeEvent(WTCollection domainAdministeredObjects,
                                                   WTCollection domainAdminRefs)
                                            throws WTException
Updates the domain of the family table objects associated to the top generic whose domain is changed. If the domain of the family table is different from what the domain of the top generic used to be, no change is made to the family table.

Throws:
WTException

getID

private static Long getID(EPMDocument document,
                          boolean useMasterID)
                   throws WTException
Returns a Long object of either Branch ID or Master ID.

Throws:
WTException

getTargetDomain

private static WTKeyedMap getTargetDomain(WTKeyedMap infoByDocuments,
                                          boolean useMasterID)
                                   throws WTException
Returns the family tables associated to the latest and the related document iterations. The new domain of family tables' is also returned. Related iterations are either all iterations w/the same master or all iterations on the same branch. It then finds the family tables associated to the iterations. The new domain of the associated family tables is the new domain associated to the latest document iteration. If the domain of the family table is different from the "old" domain of the latest document, the family table is not updated. This handles the case when an instance is checked out to project and the domain of the top generic in PDM is changed.

Parameters:
infoByDocuments - a map whose keys are the latest documents and whose values are the DomainInfo objects.
useMasterID - a flag indicating what iterations of the given documents should be used to find the associated family tables. If true, gets family tables associated to the documents w/the given documents' masters. Otherwise, gets family tables associated to all iterations on the same documents' branch.
Returns:
WTKeyedMap a map whose keys are the associated family tables and whose values are their new domain.
Throws:
WTException

createFTQuery

private static QuerySpec createFTQuery(WTCollection documents,
                                       boolean useMasterID)
                                throws WTException
Returns a query spec which retrieves the family tables associated to iterations either w/the same master or on the same branch of the given documents.

Throws:
WTException

sortByID

private static Map sortByID(WTKeyedMap byDocuments,
                            boolean useMasterID)
                     throws WTException
Sorts the objects by the documents' master ID or branch ID.

Throws:
WTException

isSameDomain

public static boolean isSameDomain(AdminDomainRef domainX,
                                   AdminDomainRef domainY)
                            throws WTException
Returns true if the domains passed in are the same.

Throws:
WTException

getTopGenericDocuments

public static WTCollection getTopGenericDocuments(WTCollection objects)
                                           throws WTException
Given a list of objects, returns only the top generic documents.

Throws:
WTException

createDomainInfo

public static WTKeyedMap createDomainInfo(WTCollection documents)
                                   throws WTException
Creates a DomainInfo object for each document. The DomainInfo object is then indexed by the document.

Parameters:
documents - a list of documents which have the "old" domain.
Throws:
WTException

createDomainInfo

private static WTKeyedMap createDomainInfo(WTCollection documents,
                                           WTKeyedMap domainByDocument)
                                    throws WTException
Creates a DomainInfo object for each document. Returns a map whose keys are the documents and whose values are the DomainInfo objects.

Parameters:
documents - a list of documents which have the "new" domain.
domainByDocument - a map whose keys are the documents and whose values are the "old" domain.
Throws:
WTException

sortByValue

private static WTKeyedMap sortByValue(WTKeyedMap map)
                               throws WTException
Returns a WTKeyedMap w/the reversed key and value. The value of the returned map is a set of the keys w/the same value.

Parameters:
map - whose keys and values are Persistable objects.
Throws:
WTException

setNewDomain

private static void setNewDomain(WTKeyedMap infoByDocument)
                          throws WTException
Updates the new domain on DomainInfo with the document's current domain.

Throws:
WTException

removeUnchangedDomain

public static void removeUnchangedDomain(WTKeyedMap infoByDocument)
                                  throws WTException
Remove objects whose domains are not changed.

Throws:
WTException

removeNoPredecessor

private static void removeNoPredecessor(WTCollection iterations)
                                 throws WTException
Remove the given objects w/no predecessors.

Throws:
WTException

filterAndCreateDomainInfo

public static WTKeyedMap filterAndCreateDomainInfo(WTCollection documents,
                                                   boolean isAllVersions)
                                            throws WTException
Given a list of documents, creates a DomainInfo objects for each top generic document. In addition, filters out documents that have more than one iteration on the same version if isAllVersions is true. Otherwise, filters out documents that are the first iteration of the first version.

Parameters:
documents - a list of documents
isAllVersions - a flag indicating how to further filter the documents. If true, keeps documents at its second or greater iteration on the version. If false, keeps documents which have predecessors.
Throws:
WTException