KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > entity > cmp2 > CascadeDeleteNotSupportedForManyMany


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.tools.verifier.tests.ejb.entity.cmp2;
25
26 import java.util.*;
27 import com.sun.enterprise.deployment.*;
28 import com.sun.enterprise.tools.verifier.Result;
29 import com.sun.enterprise.tools.verifier.tests.*;
30
31
32 /**
33  * cascade-delete tag is not supported for many-many relationships
34  *
35  * @author Sheetal Vartak
36  * @version
37  */

38 public class CascadeDeleteNotSupportedForManyMany extends CmrFieldTest {
39
40     /**
41      * run an individual verifier test of a declated cmr field of the class
42      *
43      * @param entity the descriptor for the entity bean containing the cmp-field
44      * @param info the descriptor for the declared cmr field
45      * @param c the class owning the cmp field
46      * @parma r the result object to use to put the test results in
47      *
48      * @return true if the test passed
49      */

50     protected boolean runIndividualCmrTest(Descriptor descriptor, RelationRoleDescriptor role, Class JavaDoc c, Result result) {
51     boolean isMany = false;
52     boolean isPartnerMany = false;
53     boolean cascadeDelete = false;
54     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
55
56     isMany = role.getIsMany();
57     isPartnerMany = (role.getPartner()).getIsMany();
58     cascadeDelete = role.getCascadeDelete();
59     if(isMany && isPartnerMany && cascadeDelete) {
60         addErrorDetails(result, compName);
61         result.addErrorDetails(smh.getLocalString
62            (getClass().getName() + ".failed",
63             "Error: cascade-delete should not be supported for many-many relationships. Please check Relationship Role [{0}]",
64                 new Object JavaDoc[] {role.getName()}));
65         return false;
66     } else {
67          result.addGoodDetails(smh.getLocalString
68                        ("tests.componentNameConstructor",
69                     "For [ {0} ]",
70                     new Object JavaDoc[] {compName.toString()}));
71         result.addGoodDetails(smh.getLocalString
72                (getClass().getName() + ".passed",
73             "cascade-delete is not supported for many-many relationships. Test passed.",
74                 new Object JavaDoc[] {}));
75         return true;
76     }
77     }
78 }
79
Popular Tags