Java Doc for ObjectEnvelopeOrdering.java in  » Database-ORM » db-ojb » org » apache » ojb » odmg » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » db ojb » org.apache.ojb.odmg 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.ojb.odmg.ObjectEnvelopeOrdering

ObjectEnvelopeOrdering
class ObjectEnvelopeOrdering (Code)

Implements an algorithm for reordering the object envelopes of a pending transaction to minimized the probability of foreign key constraint violations.

The algorithm is based on a graph theoretical approach: Each object envelope is represented by a vertex in a graph. Each possible constraint on the order of database operations is represented by a directed edge in this graph, in which the initial vertex represents the object envelope to be sent to the database first and the terminal index represents the object envelope that might cause a FK violation if the initial vertex has not been sent to the database before.

Additionally the edges in this graph are weighted. This is necessary because the object envelopes provide only information on the relation between objects after the transaction. FK violations, however, can also occur due to relations that existed before the transaction. Therefore the algorithm also considers potential relations between objects due to the fact that an object is of a class that is the item class of a object or collection reference of another object. Graph edges representing such potential relationships receive a lower weight than edges representing concrete relationships that exist in the current state of the object model.

Once all graph edges have been established, the algorithm proceeds as follows:

  1. Iterate through all vertices and sum up the weight of all incoming edges (i.e. those edges whose terminal vertex is the current vertex).
  2. Find the minimum value of this weight sums (ideally this minimum is zero, meaning that there are object envelopes that can be sent to the database without risking FK violations)
  3. Add all vertices with a weight sum that is equal to this minimum to the reordered sequence of object envelopes and remove the vertices and all connected edges from the graph.
  4. If there are vertices left, repeat steps (1) through (3), otherwise we are done.

author:
   Gerhard Grosse
version:
   $Id: ObjectEnvelopeOrdering.java,v 1.1.2.9 2005/12/21 22:29:21 tomdz Exp $
since:
   Nov 15, 2004



Constructor Summary
public  ObjectEnvelopeOrdering(List originalOrder, Map envelopes)
    

Method Summary
protected  EdgebuildConcrete11Edge(Vertex vertex1, Vertex vertex2, boolean fkToRef)
     Checks if the database operations associated with two object envelopes that are related via an 1:1 (or n:1) reference needs to be performed in a particular order and if so builds and returns a corresponding directed edge weighted with CONCRETE_EDGE_WEIGHT.
protected  EdgebuildConcrete1NEdge(Vertex vertex1, Vertex vertex2)
     Checks if the database operations associated with two object envelopes that are related via an 1:n collection reference needs to be performed in a particular order and if so builds and returns a corresponding directed edge weighted with CONCRETE_EDGE_WEIGHT.
protected  EdgebuildConcreteMNEdge(Vertex vertex1, Vertex vertex2)
     Checks if the database operations associated with two object envelopes that are related via an m:n collection reference needs to be performed in a particular order and if so builds and returns a corresponding directed edge weighted with CONCRETE_EDGE_WEIGHT.
protected  EdgebuildPotential11Edge(Vertex vertex1, Vertex vertex2, boolean fkToRef)
     Checks if the database operations associated with two object envelopes that might have been related via an 1:1 (or n:1) reference before the current transaction needs to be performed in a particular order and if so builds and returns a corresponding directed edge weighted with POTENTIAL_EDGE_WEIGHT.
protected  EdgebuildPotential1NEdge(Vertex vertex1, Vertex vertex2)
     Checks if the database operations associated with two object envelopes that are might have been related via an 1:n collection reference before the current transaction needs to be performed in a particular order and if so builds and returns a corresponding directed edge weighted with POTENTIAL_EDGE_WEIGHT.
protected  EdgebuildPotentialMNEdge(Vertex vertex1, Vertex vertex2)
     Checks if the database operations associated with two object envelopes that might have been related via an m:n collection reference before the current transaction needs to be performed in a particular order and if so builds and returns a corresponding directed edge weighted with POTENTIAL_EDGE_WEIGHT.
public  Identity[]getOrdering()
    
public  voidreorder()
     Reorders the object envelopes.


Constructor Detail
ObjectEnvelopeOrdering
public ObjectEnvelopeOrdering(List originalOrder, Map envelopes)(Code)
Creates an object envelope ordering based on an original ordering of Identity objects and an Identity->ObjectEnvelope map
Parameters:
  originalOrder - a list of Identity objects
Parameters:
  envelopes - a map with ObjectEnvelope-s with their respectiveIdentity-s as key




Method Detail
buildConcrete11Edge
protected Edge buildConcrete11Edge(Vertex vertex1, Vertex vertex2, boolean fkToRef)(Code)
Checks if the database operations associated with two object envelopes that are related via an 1:1 (or n:1) reference needs to be performed in a particular order and if so builds and returns a corresponding directed edge weighted with CONCRETE_EDGE_WEIGHT. The following cases are considered (* means object needs update, + means object needs insert, - means object needs to be deleted):
(1)* -(1:1)-> (2)*no edge
(1)* -(1:1)-> (2)+(2)->(1) edge
(1)* -(1:1)-> (2)-no edge (cannot occur)
(1)+ -(1:1)-> (2)*no edge
(1)+ -(1:1)-> (2)+(2)->(1) edge
(1)+ -(1:1)-> (2)-no edge (cannot occur)
(1)- -(1:1)-> (2)*no edge
(1)- -(1:1)-> (2)+no edge
(1)- -(1:1)-> (2)-(1)->(2) edge

Parameters:
  vertex1 - object envelope vertex of the object holding the reference
Parameters:
  vertex2 - object envelope vertex of the referenced object an Edge object or null if the two database operations canbe performed in any order



buildConcrete1NEdge
protected Edge buildConcrete1NEdge(Vertex vertex1, Vertex vertex2)(Code)
Checks if the database operations associated with two object envelopes that are related via an 1:n collection reference needs to be performed in a particular order and if so builds and returns a corresponding directed edge weighted with CONCRETE_EDGE_WEIGHT. The following cases are considered (* means object needs update, + means object needs insert, - means object needs to be deleted):
(1)* -(1:n)-> (2)*no edge
(1)* -(1:n)-> (2)+no edge
(1)* -(1:n)-> (2)-no edge
(1)+ -(1:n)-> (2)*(1)->(2) edge
(1)+ -(1:n)-> (2)+(1)->(2) edge
(1)+ -(1:n)-> (2)-no edge (cannot occur)
(1)- -(1:n)-> (2)*(2)->(1) edge
(1)- -(1:n)-> (2)+no edge
(1)- -(1:n)-> (2)-(2)->(1) edge

Parameters:
  vertex1 - object envelope vertex of the object holding the collection
Parameters:
  vertex2 - object envelope vertex of the object contained in the collection an Edge object or null if the two database operations canbe performed in any order



buildConcreteMNEdge
protected Edge buildConcreteMNEdge(Vertex vertex1, Vertex vertex2)(Code)
Checks if the database operations associated with two object envelopes that are related via an m:n collection reference needs to be performed in a particular order and if so builds and returns a corresponding directed edge weighted with CONCRETE_EDGE_WEIGHT. The following cases are considered (* means object needs update, + means object needs insert, - means object needs to be deleted):
(1)* -(m:n)-> (2)*no edge
(1)* -(m:n)-> (2)+(2)->(1) edge
(1)* -(m:n)-> (2)-no edge (cannot occur)
(1)+ -(m:n)-> (2)*no edge
(1)+ -(m:n)-> (2)+(2)->(1) edge
(1)+ -(m:n)-> (2)-no edge (cannot occur)
(1)- -(m:n)-> (2)*no edge
(1)- -(m:n)-> (2)+no edge
(1)- -(m:n)-> (2)-(1)->(2) edge

Parameters:
  vertex1 - object envelope vertex of the object holding the collection
Parameters:
  vertex2 - object envelope vertex of the object contained in the collection an Edge object or null if the two database operations canbe performed in any order



buildPotential11Edge
protected Edge buildPotential11Edge(Vertex vertex1, Vertex vertex2, boolean fkToRef)(Code)
Checks if the database operations associated with two object envelopes that might have been related via an 1:1 (or n:1) reference before the current transaction needs to be performed in a particular order and if so builds and returns a corresponding directed edge weighted with POTENTIAL_EDGE_WEIGHT. The following cases are considered (* means object needs update, + means object needs insert, - means object needs to be deleted):
(1)* -(1:1)-> (2)*no edge
(1)* -(1:1)-> (2)+no edge
(1)* -(1:1)-> (2)-(1)->(2) edge
(1)+ -(1:1)-> (2)*no edge
(1)+ -(1:1)-> (2)+no edge
(1)+ -(1:1)-> (2)-no edge
(1)- -(1:1)-> (2)*no edge
(1)- -(1:1)-> (2)+no edge
(1)- -(1:1)-> (2)-(1)->(2) edge

Parameters:
  vertex1 - object envelope vertex of the object that might have hold the reference
Parameters:
  vertex2 - object envelope vertex of the potentially referenced object an Edge object or null if the two database operations canbe performed in any order



buildPotential1NEdge
protected Edge buildPotential1NEdge(Vertex vertex1, Vertex vertex2)(Code)
Checks if the database operations associated with two object envelopes that are might have been related via an 1:n collection reference before the current transaction needs to be performed in a particular order and if so builds and returns a corresponding directed edge weighted with POTENTIAL_EDGE_WEIGHT. The following cases are considered (* means object needs update, + means object needs insert, - means object needs to be deleted):
(1)* -(1:n)-> (2)*no edge
(1)* -(1:n)-> (2)+no edge
(1)* -(1:n)-> (2)-no edge
(1)+ -(1:n)-> (2)*no edge
(1)+ -(1:n)-> (2)+no edge
(1)+ -(1:n)-> (2)-no edge
(1)- -(1:n)-> (2)*(2)->(1) edge
(1)- -(1:n)-> (2)+no edge
(1)- -(1:n)-> (2)-(2)->(1) edge

Parameters:
  vertex1 - object envelope vertex of the object holding the collection
Parameters:
  vertex2 - object envelope vertex of the object that might havebeen contained in the collection an Edge object or null if the two database operations canbe performed in any order



buildPotentialMNEdge
protected Edge buildPotentialMNEdge(Vertex vertex1, Vertex vertex2)(Code)
Checks if the database operations associated with two object envelopes that might have been related via an m:n collection reference before the current transaction needs to be performed in a particular order and if so builds and returns a corresponding directed edge weighted with POTENTIAL_EDGE_WEIGHT. The following cases are considered (* means object needs update, + means object needs insert, - means object needs to be deleted):
(1)* -(m:n)-> (2)*no edge
(1)* -(m:n)-> (2)+no edge
(1)* -(m:n)-> (2)-(1)->(2) edge
(1)+ -(m:n)-> (2)*no edge
(1)+ -(m:n)-> (2)+no edge
(1)+ -(m:n)-> (2)-no edge
(1)- -(m:n)-> (2)*no edge
(1)- -(m:n)-> (2)+no edge
(1)- -(m:n)-> (2)-(1)->(2) edge

Parameters:
  vertex1 - object envelope vertex of the object holding the collection
Parameters:
  vertex2 - object envelope vertex of the object that might havebeen contained in the collection an Edge object or null if the two database operations canbe performed in any order



getOrdering
public Identity[] getOrdering()(Code)
Gets the reordered sequence of object envelopes an array of Identity objects representing the opimized sequenceof database operations



reorder
public void reorder()(Code)
Reorders the object envelopes. The new order is available from the ordering property.
See Also:   ObjectEnvelopeOrdering.getOrdering()



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.