/**
* Construct a description of view changes based on the supplied drop and deploy requirements
* together with some dependency analysis.
*
* <p>The drop set is expanded based on dependency analysis: any view that depends on a dropped
* view will also be dropped.</p>
*
* <p>The deployment set is expanded only to include the items that are added to the drop set -
* i.e. if we determine that a view needs to be recreated because a dependencies is dropped,
* then it will be added to both the drop and deploy sets. Views will not be added to the
* deploy set based on dependency analysis - it is assumed that all missing views will
* already be in the deploy set.</p>
*
* <p>All parameters may be immutable.</p>
*
* @param allViews all the views as defined in the codeset and bound in to the application. This is the 'source of truth' as to which views are available.
* @param viewsToDrop Views which should be dropped from the current schema. Caller must ensure names are unique within the collection.
* @param viewsToDeploy Views which should be deployed from the target schema. Caller must ensure names are unique within the collection.
*/
public ViewChanges(Collection<View> allViews, Collection<View> viewsToDrop, Collection<View> viewsToDeploy) {
super();
// -- Store our dependency information as we may need to pass it on...
//
this.allViews = allViews;
// -- Work with sets of strings internally, we switch back to views when we return ordered lists...
//
this.knownSet = newHashSet(Collections2.transform(allViews, viewToName()));
this.dropSet = newHashSet(correctCase(Collections2.transform(viewsToDrop, viewToName())));
this.deploySet = newHashSet(Collections2.transform(viewsToDeploy, viewToName()));
// -- Maintain an index of name to view so we can convert back. Must contain allViews + viewsToDrop for obsolete views...
//
viewIndex.putAll(uniqueIndex(viewsToDrop, viewToName()));
viewIndex.putAll(uniqueIndex(allViews, viewToName())); // known views take precedence as we have more complete info
// -- Perform a topological sort of all dependent views (based on bound in views, not the contents of the DB)...
//
viewCreationOrder = topoSortViews(allViews, viewIndex);
// -- Add any obsolete views back into the order in an arbitrary position (they need to be dropped
// but we have no dependency information to indicate where)...
//
viewCreationOrder.addAll(Sets.difference(newHashSet(this.dropSet), newHashSet(this.knownSet)));
}
ViewChanges.java 文件源码
java
阅读 30
收藏 0
点赞 0
评论 0
项目:morf
作者:
评论列表
文章目录