]> SALOME platform Git repositories - modules/gde.git/commitdiff
Salome HOME
ProfileDaoClient
authorKavoos Bojnourdi <kavoos.bojnourdi@edf.fr>
Sat, 15 Aug 2015 11:03:06 +0000 (13:03 +0200)
committerKavoos Bojnourdi <kavoos.bojnourdi@edf.fr>
Sat, 15 Aug 2015 11:03:06 +0000 (13:03 +0200)
projects/GDE_App/GDE-war/src/java/com/edf/gde/services/ProfilesService.java
projects/GDE_App/GDE-war/test/com/edf/gde/dao/BaseDao.java
projects/GDE_App/GDE-war/test/com/edf/gde/dao/ProfileDaoClient.java [new file with mode: 0644]

index f357865d546d5fefa37041c1aee6adea9f814f95..e0ead9031d49022f1340a82d1d51f0711b486fcf 100644 (file)
@@ -20,7 +20,7 @@ import javax.servlet.http.HttpServletResponse;
  *
  * @author Kavoos
  */
-public class ProfileService extends BaseService {
+public class ProfilesService extends BaseService {
 
     public static final String ServiceName = "AttributesService";
     public static final int CREATEPROFILE = 1;
index 51e929a2557b34966f8734d4142a83100c7c978c..cb81114916c19c438c8cd16393ac3737f64e1f5a 100644 (file)
@@ -75,12 +75,12 @@ public abstract class BaseDao extends SimpleRestApi {
     }
 
     /**
-     *
-     * @param <T>
-     * @param commandTO
-     * @param object
-     * @param classOf
-     * @return
+     * Post a command
+     * @param <T> 
+     * @param commandTO 
+     * @param object Object to be posted or null if no object
+     * @param classOf Type of the return value 
+     * @return Return a value of type T
      * @throws IOException
      */
     protected <T> T postCommand(CommandTO commandTO, Object object, Class<T> classOf) throws IOException {
@@ -98,9 +98,9 @@ public abstract class BaseDao extends SimpleRestApi {
     }
 
     /**
-     *
+     * Post a command
      * @param commandTO
-     * @param object
+     * @param object Object to be posted or null if no object
      * @throws IOException
      */
     protected void postCommand(CommandTO commandTO, Object object) throws IOException {
diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/dao/ProfileDaoClient.java b/projects/GDE_App/GDE-war/test/com/edf/gde/dao/ProfileDaoClient.java
new file mode 100644 (file)
index 0000000..071bbb6
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * (C) 2015 EDF
+ */
+package com.edf.gde.dao;
+
+import com.edf.gde.transferables.CommandTO;
+import com.edf.gde.transferables.ProfileAttributeTO;
+import com.edf.gde.transferables.ProfileTO;
+import java.io.IOException;
+import restapi.RestContext;
+
+/**
+ *
+ * @author mordicus
+ */
+public class ProfileDaoClient extends BaseDao {
+
+    public static final String ServiceName = "AttributesService";
+    public static final int CREATEPROFILE = 1;
+    public static final int DELETEPROFILE = 2;
+    public static final int READPROFILE = 3;
+    public static final int UPDATEPROFILE = 4;
+    public static final int CREATEPROFILEATTRIBUTE = 5;
+    public static final int DELETEPROFILEATTRIBUTE = 6;
+    public static final int READPROFILEATTRIBUTE = 7;
+    public static final int UPDATEPROFILEATTRIBUTE = 8;
+
+    public ProfileDaoClient() {
+        getContext().setBaseResource("http://localhost:8080/GDE-war/ProfileService");
+        getContext().setUserName("admin");
+        getContext().setPassword("edf123");
+    }
+
+    public ProfileDaoClient(RestContext context) {
+        super(context);
+    }
+
+    public ProfileTO createProfile(ProfileTO profileTO) throws IOException {
+        CommandTO commandTO = createCommand(CREATEPROFILE);
+        return postCommand(commandTO, profileTO, ProfileTO.class);
+    }
+
+    public void deleteProfile(long profileId) throws IOException {
+        CommandTO commandTO = createCommand(DELETEPROFILE);
+        commandTO.setLong("profileId", profileId);
+        postCommand(commandTO, null);
+    }
+
+    public ProfileTO readProfile(long profileId) throws IOException {
+        CommandTO commandTO = createCommand(READPROFILE);
+        commandTO.setLong("profileId", profileId);
+        return postCommand(commandTO, null, ProfileTO.class);
+    }
+
+    public ProfileTO updateProfile(ProfileTO profileTO) throws IOException {
+        CommandTO commandTO = createCommand(UPDATEPROFILE);
+        return postCommand(commandTO, profileTO, ProfileTO.class);
+    }
+
+    public ProfileAttributeTO createProfileAttribute(ProfileAttributeTO attributeTO) throws IOException {
+        CommandTO commandTO = createCommand(CREATEPROFILEATTRIBUTE);
+        return postCommand(commandTO, attributeTO, ProfileAttributeTO.class);
+    }
+
+    public void deleteProfileAttribute(long profileAttributeId) throws IOException {
+        CommandTO commandTO = createCommand(DELETEPROFILEATTRIBUTE);
+        commandTO.setLong("profileAttributeId", profileAttributeId);
+        postCommand(commandTO, null);
+    }
+
+    public ProfileAttributeTO readProfileAttribute(long profileAttributeId) throws IOException {
+        CommandTO commandTO = createCommand(READPROFILEATTRIBUTE);
+        commandTO.setLong("profileAttributeId", profileAttributeId);
+        return postCommand(commandTO, null, ProfileAttributeTO.class);
+    }
+
+    public ProfileAttributeTO updateProfileAttribute(ProfileAttributeTO attributeTO) throws IOException {
+        CommandTO commandTO = createCommand(UPDATEPROFILEATTRIBUTE);
+        return postCommand(commandTO, attributeTO, ProfileAttributeTO.class);
+    }
+
+}