]> SALOME platform Git repositories - modules/gde.git/commitdiff
Salome HOME
Don't need sql script for DDL anymore
authorBojnourdi <kavoos.bojnourdi@edf.fr>
Fri, 28 Aug 2015 12:55:22 +0000 (14:55 +0200)
committerBojnourdi <kavoos.bojnourdi@edf.fr>
Fri, 28 Aug 2015 12:55:22 +0000 (14:55 +0200)
projects/GDE_App/GDE-ejb/src/conf/persistence.xml
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/GroupPermission.java
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/UserGroup.java
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/sql/init.sql [new file with mode: 0644]

index 669df2b43658e1089755235d47ddd2fc86dc9afa..8219a7bef0d6143a43df4ad0d9492ac4ff2a4f8e 100644 (file)
@@ -8,6 +8,7 @@
     <properties>
       <property name="eclipselink.target-database" value="PostgreSQL"/>
       <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
+      <property name="javax.persistence.sql-load-script-source" value="com/edf/gde/sql/init.sql"/>
     </properties>
   </persistence-unit>
 </persistence>
index 9fac0252436480548ad806600e88bb2aead1543f..2678e326fabe7ededb9f8c9105d80bcfa0a9f492 100644 (file)
@@ -13,6 +13,12 @@ import javax.persistence.NamedQuery;
 import javax.persistence.SequenceGenerator;
 import javax.persistence.Table;
 import javax.validation.constraints.NotNull;
+import org.eclipse.persistence.annotations.Cache;
+import org.eclipse.persistence.annotations.CacheIndex;
+import org.eclipse.persistence.annotations.CacheIndexes;
+import org.eclipse.persistence.annotations.Index;
+import org.eclipse.persistence.annotations.Indexes;
+import org.eclipse.persistence.config.CacheIsolationType;
 
 /**
  *
@@ -29,7 +35,17 @@ import javax.validation.constraints.NotNull;
             + "and g.serviceName=:serviceName "
             + "and g.methodIndex=:methodIndex")
 })
-
+@Indexes({
+    @Index(columnNames = "groupId"),
+    @Index(columnNames = "serviceName"),
+    @Index(columnNames = "methodIndex")
+})
+@CacheIndexes({
+    @CacheIndex(columnNames = "groupId"),
+    @CacheIndex(columnNames = "serviceName"),
+    @CacheIndex(columnNames = "methodIndex")
+})
+@Cache(size = 100, isolation = CacheIsolationType.SHARED)
 public class GroupPermission implements Serializable {
 
     @Id
@@ -39,11 +55,11 @@ public class GroupPermission implements Serializable {
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
     @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
     private Long id;
-    @Column(name="groupId")
+    @Column(name = "groupId")
     long groupId;
-    @Column(name="serviceName")
+    @Column(name = "serviceName")
     String serviceName;
-    @Column(name="methodIndex")
+    @Column(name = "methodIndex")
     int methodIndex;
 
     public GroupPermission() {
index 64063824986a82bdbe55b973ccd6efed34504ab1..ddf78d5f724270614f6f9056b536aecd49effe2c 100644 (file)
@@ -16,22 +16,34 @@ import javax.persistence.SequenceGenerator;
 import javax.persistence.Table;
 import javax.validation.constraints.NotNull;
 import org.eclipse.persistence.annotations.Cache;
+import org.eclipse.persistence.annotations.CacheIndex;
+import org.eclipse.persistence.annotations.CacheIndexes;
+import org.eclipse.persistence.annotations.Index;
+import org.eclipse.persistence.annotations.Indexes;
 import org.eclipse.persistence.config.CacheIsolationType;
 
 /**
  *
  * @author kavoos
  */
-@Entity(name="UserGroup")
+@Entity(name = "UserGroup")
 @Table(name = "USERGROUP")
 @Cache(size = 100, isolation = CacheIsolationType.SHARED)
-@NamedQueries ({
+@NamedQueries({
     @NamedQuery(name = "UserGroup.findById", query = "SELECT ug FROM UserGroup ug where ug.id = :id"),
     @NamedQuery(name = "UserGroup.findByUserId", query = "SELECT ug FROM UserGroup ug where ug.userId=:userId"),
-    @NamedQuery(name = "UserGroup.findByGroupId", query="SELECT ug FROM UserGroup ug where ug.groupId=:groupId"),
-    @NamedQuery(name = "UserGroup.findByGroupIdUserId",query="SELECT ug FROM UserGroup ug where ug.groupId=:groupId and ug.userId=:userId")
+    @NamedQuery(name = "UserGroup.findByGroupId", query = "SELECT ug FROM UserGroup ug where ug.groupId=:groupId"),
+    @NamedQuery(name = "UserGroup.findByGroupIdUserId", query = "SELECT ug FROM UserGroup ug where ug.groupId=:groupId and ug.userId=:userId")
 })
+@Indexes({
+    @Index(columnNames = "userId"),
+    @Index(columnNames = "groupId")
+})
+@CacheIndexes({
+    @CacheIndex(columnNames = {"userId"}),
+    @CacheIndex(columnNames = "groupId")})
 public class UserGroup {
+
     @Id
     @Basic(optional = false)
     @NotNull
@@ -39,7 +51,7 @@ public class UserGroup {
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
     @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
     private Long id;
-    @Column(name="userId")
+    @Column(name = "userId")
     long userId;
     @Column(name = "groupId")
     long groupId;
@@ -94,5 +106,5 @@ public class UserGroup {
         }
         return true;
     }
-    
+
 }
diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/sql/init.sql b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/sql/init.sql
new file mode 100644 (file)
index 0000000..41b2614
--- /dev/null
@@ -0,0 +1,45 @@
+-- The 1000 first ids are reserved for initial data
+INSERT INTO users (id,username,userpassword) VALUES (1,'admin','edf123');
+INSERT INTO group_ (id,groupname) VALUES (1,'admins');
+INSERT into usergroup(id,groupid,userid) VALUES (2,1,1);
+/* User management permissions */
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (3, 1, 'UserService',1); -- Create user 
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (4, 1, 'UserService',2); -- Delete user
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (5, 1, 'UserService',3); -- Add to group
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (6, 1, 'UserService',4); -- Remove from group
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (7, 1, 'UserService',5); -- Create group
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (8, 1, 'UserService',6); -- Delete group
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (9, 1, 'UserService',7); -- Find user
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (10, 1, 'UserService',8); -- Find group
+/* Studies permissions */
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (11, 1, 'StudyService',1); -- Create study
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (12, 1, 'StudyService',2); -- Set study state
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (13, 1, 'StudyService',3); -- Read study
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (14, 1, 'StudyService',4); -- Delete study
+/* Profiles services */
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (15, 1, 'ProfilesService',1); -- Create profile
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (16, 1, 'ProfilesService',2); -- Delete profile
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (17, 1, 'ProfilesService',3); -- Read profile
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (18, 1, 'ProfilesService',4); -- Update profile
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (19, 1, 'ProfilesService',5); -- Create profile attribute
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (20, 1, 'ProfilesService',6); -- Delete profile attribute
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (21, 1, 'ProfilesService',7); -- Read profile attribute
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (22, 1, 'ProfilesService',8); -- Update profile attribute
+/* Attributes services */
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (23, 1, 'AttributesService',1); -- Create attribute
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (24, 1, 'AttributesService',2); -- Delete attribute
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (25, 1, 'AttributesService',3); -- Read attribute
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (26, 1, 'AttributesService',4); -- Create attribute group
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (27, 1, 'AttributesService',5); -- Delete attribute group
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (28, 1, 'AttributesService',6); -- Update attribute group
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (29, 1, 'AttributesService',7); -- Read attribute group
+/* File services */ 
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (30, 1, 'FileService',1); -- 
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (31, 1, 'FileService',2); -- 
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (32, 1, 'FileService',3); -- 
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (33, 1, 'FileService',4); -- 
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (34, 1, 'FileService',5); -- 
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (35, 1, 'FileService',6); -- 
+INSERT INTO GROUPPERMISSIONS (id,groupid,servicename,methodindex) VALUES (36, 1, 'FileService',7); -- 
+
+