From: Kavoos Bojnourdi Date: Sat, 15 Aug 2015 11:03:06 +0000 (+0200) Subject: ProfileDaoClient X-Git-Tag: gde-v0.1~18^2~38 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d414e4be85cb737560cd6c042100934634d0dd29;p=modules%2Fgde.git ProfileDaoClient --- diff --git a/projects/GDE_App/GDE-war/src/java/com/edf/gde/services/ProfilesService.java b/projects/GDE_App/GDE-war/src/java/com/edf/gde/services/ProfilesService.java index f357865..e0ead90 100644 --- a/projects/GDE_App/GDE-war/src/java/com/edf/gde/services/ProfilesService.java +++ b/projects/GDE_App/GDE-war/src/java/com/edf/gde/services/ProfilesService.java @@ -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; diff --git a/projects/GDE_App/GDE-war/test/com/edf/gde/dao/BaseDao.java b/projects/GDE_App/GDE-war/test/com/edf/gde/dao/BaseDao.java index 51e929a..cb81114 100644 --- a/projects/GDE_App/GDE-war/test/com/edf/gde/dao/BaseDao.java +++ b/projects/GDE_App/GDE-war/test/com/edf/gde/dao/BaseDao.java @@ -75,12 +75,12 @@ public abstract class BaseDao extends SimpleRestApi { } /** - * - * @param - * @param commandTO - * @param object - * @param classOf - * @return + * Post a command + * @param + * @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 postCommand(CommandTO commandTO, Object object, Class 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 index 0000000..071bbb6 --- /dev/null +++ b/projects/GDE_App/GDE-war/test/com/edf/gde/dao/ProfileDaoClient.java @@ -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); + } + +}