cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [8/23] git commit: added JoinType to remove the j2ee source code in CloudStack
Date Thu, 09 Aug 2012 01:41:08 GMT
added JoinType to remove the j2ee source code in CloudStack


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/e83c60a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/e83c60a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/e83c60a0

Branch: refs/heads/vpc
Commit: e83c60a057abfa2554a9d7ab0d03c191c6a7d815
Parents: 2ce632c
Author: Alex Huang <alex.huang@citrix.com>
Authored: Wed Aug 8 13:34:02 2012 -0700
Committer: Alex Huang <alex.huang@citrix.com>
Committed: Wed Aug 8 13:42:08 2012 -0700

----------------------------------------------------------------------
 .../network/security/SecurityGroupRulesVO.java     |    2 +
 utils/src/com/cloud/utils/db/JoinType.java         |   32 +++++++++++++++
 utils/src/com/cloud/utils/db/SqlGenerator.java     |    7 +++-
 3 files changed, 40 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e83c60a0/core/src/com/cloud/network/security/SecurityGroupRulesVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/network/security/SecurityGroupRulesVO.java b/core/src/com/cloud/network/security/SecurityGroupRulesVO.java
index a671e30..d322a79 100644
--- a/core/src/com/cloud/network/security/SecurityGroupRulesVO.java
+++ b/core/src/com/cloud/network/security/SecurityGroupRulesVO.java
@@ -26,9 +26,11 @@ import javax.persistence.SecondaryTable;
 import javax.persistence.Table;
 
 import com.cloud.network.security.SecurityRule.SecurityRuleType;
+import com.cloud.utils.db.JoinType;
 
 @Entity
 @Table(name = ("security_group"))
+@JoinType(type = "left")
 @SecondaryTable(name = "security_group_rule", pkJoinColumns = { @PrimaryKeyJoinColumn(name
= "id", referencedColumnName = "security_group_id") })
 public class SecurityGroupRulesVO implements SecurityGroupRules {
     @Id

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e83c60a0/utils/src/com/cloud/utils/db/JoinType.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/JoinType.java b/utils/src/com/cloud/utils/db/JoinType.java
new file mode 100755
index 0000000..6861925
--- /dev/null
+++ b/utils/src/com/cloud/utils/db/JoinType.java
@@ -0,0 +1,32 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.utils.db;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * JoinType is only used with SecondaryTable.  Temporary solution.   
+ */
+@Target(TYPE)
+@Retention(RUNTIME)
+public @interface JoinType {
+    String type() default "inner";
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e83c60a0/utils/src/com/cloud/utils/db/SqlGenerator.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/SqlGenerator.java b/utils/src/com/cloud/utils/db/SqlGenerator.java
index 437cad1..3b2d8cd 100755
--- a/utils/src/com/cloud/utils/db/SqlGenerator.java
+++ b/utils/src/com/cloud/utils/db/SqlGenerator.java
@@ -539,7 +539,12 @@ public class SqlGenerator {
         SecondaryTable[] sts = DbUtil.getSecondaryTables(clazz);
         ArrayList<String> secondaryTables = new ArrayList<String>();
         for (SecondaryTable st : sts) {
-            addPrimaryKeyJoinColumns(innerJoin, tableName, st.name(), "", st.pkJoinColumns());
+            JoinType jt = clazz.getAnnotation(JoinType.class);
+            String join = null;
+            if (jt != null) {
+                join = jt.type();
+            }
+            addPrimaryKeyJoinColumns(innerJoin, tableName, st.name(), join, st.pkJoinColumns());
             secondaryTables.add(st.name());
         }
 


Mime
View raw message