[Nextobjects-devel] nextobjects/nextobjects/src/org/devaki/nextobjects/util CDMVerifier.java,1.4,1.5
Status: Alpha
Brought to you by:
eflorent
Update of /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/util
In directory sc8-pr-cvs1:/tmp/cvs-serv28400/src/org/devaki/nextobjects/util
Modified Files:
CDMVerifier.java EditorFactory.java MeriseTransform.java
NOTools.java
Log Message:
Fixed major bugs in merise transformation.
Index: CDMVerifier.java
===================================================================
RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/util/CDMVerifier.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** CDMVerifier.java 5 Apr 2003 10:37:17 -0000 1.4
--- CDMVerifier.java 25 May 2003 20:21:10 -0000 1.5
***************
*** 125,130 ****
for (int i=0;i<fieldList.size();i++) {
if(!s.add(((String[])fieldList.elementAt(i))[1])) {
! errors++;
! logger.error( ((String[])fieldList.elementAt(i))[1]
+ " is not unique in "
+ ((String[])fieldList.elementAt(i))[0]);
--- 125,130 ----
for (int i=0;i<fieldList.size();i++) {
if(!s.add(((String[])fieldList.elementAt(i))[1])) {
! warnings++;
! logger.warn( ((String[])fieldList.elementAt(i))[1]
+ " is not unique in "
+ ((String[])fieldList.elementAt(i))[0]);
Index: EditorFactory.java
===================================================================
RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/util/EditorFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** EditorFactory.java 5 May 2003 21:01:27 -0000 1.3
--- EditorFactory.java 25 May 2003 20:21:10 -0000 1.4
***************
*** 63,76 ****
/**
! * Call the any object editing window
* @return
*/
public static void getObjectEdit( )
{
- System.out.println("2getModelEdit()");
BaseObject currentObject=ModelMan.getCurrentObject();
if (ModelMan.getCurrentObjects().isEmpty())
{
- System.out.println("getModelEdit()");
EditorFactory.getModelEdit();
}
--- 63,75 ----
/**
! * Call current object editing window
! * If no current object return current model object
* @return
*/
public static void getObjectEdit( )
{
BaseObject currentObject=ModelMan.getCurrentObject();
if (ModelMan.getCurrentObjects().isEmpty())
{
EditorFactory.getModelEdit();
}
Index: MeriseTransform.java
===================================================================
RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/util/MeriseTransform.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** MeriseTransform.java 25 May 2003 08:02:36 -0000 1.15
--- MeriseTransform.java 25 May 2003 20:21:10 -0000 1.16
***************
*** 321,346 ****
}
private static void applyRule_1N_(PhysicalModel theDatabase,
Association pAsso)
{
! // Rule 3 : : In the case of entities connected by associations of the 1:n
! // type, each table has its own key, but the key of the entity side 0,n (or
! // 1,n) migrates towards the table side 0,1 (or 1,1) and becomes a foreign
! // key (secondary index).
!
Column newField;
! Constraint newCst=new Constraint(theDatabase,
! pAsso.getEntityAt(0).getSubsequentTable(),
! pAsso.getEntityAt(1).getSubsequentTable());
! if (pAsso.getCardAt(0)==ConceptualModel._0N_
! && pAsso.getCardAt(0)==ConceptualModel._1N_)
{
// ...
newField=new Column(pAsso.getEntityAt(1).getIdentifier());
! newField.setAutoIncrement(false); // always in that case!
pAsso.getEntityAt(0).getSubsequentTable().getData().addElement(newField);
// If the type of relation is 1:n, it is advisable to make slip the
! // attributes towards entitY provided with cardinalities the 1:1.
for (int i=0;i<pAsso.getData().size();i++)
{
--- 321,361 ----
}
+
+ /*
+ * This transformation rule deal with 1 --> * relation.
+ *
+ * Rule 3 : : In the case of entities connected by associations of the 1:n
+ * type, each table has its own key, but the key of the entity side 0,n (or
+ * 1,n) migrates towards the table side 0,1 (or 1,1) and becomes a foreign
+ * key (secondary index).
+ *
+ * Thanks to Romeo Benzoni for his submission/review.
+ *
+ * @param theDatabase Database context
+ * @param theAssociation Association to be treated
+ * @see http://www.devaki.org/transformation.html
+ */
+
private static void applyRule_1N_(PhysicalModel theDatabase,
Association pAsso)
{
! /* Rule 3 */
Column newField;
! Constraint newCst=null;
! // here we try to reach the left or the right part of the Association Class.
! // I mean not the cards or anything but find the side we want: side-N vs side-1
! if (pAsso.getCardAt(1)==ConceptualModel._0N_
! || pAsso.getCardAt(1)==ConceptualModel._1N_)
{
// ...
+ newCst=new Constraint(theDatabase,
+ pAsso.getEntityAt(1).getSubsequentTable(),
+ pAsso.getEntityAt(0).getSubsequentTable());
newField=new Column(pAsso.getEntityAt(1).getIdentifier());
!
pAsso.getEntityAt(0).getSubsequentTable().getData().addElement(newField);
// If the type of relation is 1:n, it is advisable to make slip the
! // attributes towards entity provided with cardinalities the 1:1.
for (int i=0;i<pAsso.getData().size();i++)
{
***************
*** 353,360 ****
newCst.setAnyField(newField);
pAsso.getEntityAt(0).getSubsequentTable().setIdMethod("none");
} else {
! // ...
newField=new Column(pAsso.getEntityAt(0).getIdentifier());
! newField.setAutoIncrement(false);
pAsso.getEntityAt(1).getSubsequentTable().getData().addElement(newField);
--- 368,394 ----
newCst.setAnyField(newField);
pAsso.getEntityAt(0).getSubsequentTable().setIdMethod("none");
+
+ if (pAsso.getCardAt(1)==ConceptualModel._0N_
+ | pAsso.getCardAt(0)==ConceptualModel._01_) {
+ newField.setRequired(false);
+ } else {
+ //force cause we have a 1 in 1N.
+ // (even if it'salways already set, the value is forced)
+ newField.setRequired(true);
+ }
+ // to do implement isPk for 11 !!!
+ newField.setPrimaryKey(false);
+
+ // as a FK it never autoincrement
+ newField.setAutoIncrement(false);
+
+ // now we change side and to the same work.
+ // EntityAt(0) is EntityAt(1) and vice-versa.
} else {
! newCst=new Constraint(theDatabase,
! pAsso.getEntityAt(0).getSubsequentTable(),
! pAsso.getEntityAt(1).getSubsequentTable());
newField=new Column(pAsso.getEntityAt(0).getIdentifier());
!
pAsso.getEntityAt(1).getSubsequentTable().getData().addElement(newField);
***************
*** 369,373 ****
--- 403,421 ----
newCst.setAnyField(newField);
pAsso.getEntityAt(1).getSubsequentTable().setIdMethod("none");
+
+ if (pAsso.getCardAt(0)==ConceptualModel._0N_
+ | pAsso.getCardAt(1)==ConceptualModel._01_) {
+ newField.setRequired(false);
+ } else {
+ //force cause we have a 1 in 1N.
+ // (even if it'salways already set, the value is forced)
+ newField.setRequired(true);
+ }
+ // to do implement isPk for 11 !!!
+ newField.setPrimaryKey(false);
+
+ newField.setAutoIncrement(false);
}
+
ModelMan.addConstraint(theDatabase,newCst);
}
***************
*** 427,429 ****
ModelMan.addTable(theDatabase,newTable);
}
! }
\ No newline at end of file
--- 475,477 ----
ModelMan.addTable(theDatabase,newTable);
}
! }
Index: NOTools.java
===================================================================
RCS file: /cvsroot/nextobjects/nextobjects/nextobjects/src/org/devaki/nextobjects/util/NOTools.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** NOTools.java 25 May 2003 08:02:36 -0000 1.11
--- NOTools.java 25 May 2003 20:21:10 -0000 1.12
***************
*** 216,220 ****
{
FileOutputStream file = new FileOutputStream(NO_PREFS);
! NO_PROPS.store(file, "nextObjects preferences");
file.flush();
file.close();
--- 216,220 ----
{
FileOutputStream file = new FileOutputStream(NO_PREFS);
! NO_PROPS.store(file, "NextObjects preferences");
file.flush();
file.close();
***************
*** 514,524 ****
* a given association (cardinalities)
*
! * card_is 01 11 0N 1N
! * is_card ---------------------------------
! * 01 | 11 11 NM NM
* 11 | 11 11 1N 1N
! * 0N | NM 1N NM NM
! * 1N | NM 1N NM NM
! *
* @param theAssociation
* @return
--- 514,524 ----
* a given association (cardinalities)
*
! * card_is 01 11 0N 1N (right)
! * is_card --------------------------------
! * 01 | 11 11 1N 1N
* 11 | 11 11 1N 1N
! * 0N | 1N 1N NM NM
! * 1N | 1N 1N NM NM
! * (left)
* @param theAssociation
* @return
***************
*** 529,536 ****
int is_card=((AssociationLink)theAssociation.getMyAssociationLinks().elementAt(1)).getCard();
! int [][] results= { {ConceptualModel._11_ ,ConceptualModel._11_ ,ConceptualModel._NM_ ,ConceptualModel._NM_ },
! {ConceptualModel._11_,ConceptualModel._11_ ,ConceptualModel._1N_ ,ConceptualModel._1N_ },
! {ConceptualModel._NM_ ,ConceptualModel._1N_ ,ConceptualModel._NM_ ,ConceptualModel._NM_ },
! {ConceptualModel._NM_,ConceptualModel._1N_ ,ConceptualModel._NM_ ,ConceptualModel._NM_ }} ;
int cardType=results[card_is][is_card];
--- 529,536 ----
int is_card=((AssociationLink)theAssociation.getMyAssociationLinks().elementAt(1)).getCard();
! int [][] results= { {ConceptualModel._11_ ,ConceptualModel._11_ ,ConceptualModel._1N_ ,ConceptualModel._1N_ },
! {ConceptualModel._11_,ConceptualModel._11_ ,ConceptualModel._1N_ ,ConceptualModel._1N_ },
! {ConceptualModel._1N_ ,ConceptualModel._1N_ ,ConceptualModel._NM_ ,ConceptualModel._NM_ },
! {ConceptualModel._1N_,ConceptualModel._1N_ ,ConceptualModel._NM_ ,ConceptualModel._NM_ }} ;
int cardType=results[card_is][is_card];
|