use of com.remswork.project.alice.model.Activity in project classify-system by anverliedoit.
the class ActivityAdapterF method onBindViewHolder.
@Override
public void onBindViewHolder(ActivityViewHolder holder, int position) {
Activity activity = activityList.get(position);
holder.setView(activity, position);
}
use of com.remswork.project.alice.model.Activity in project classify-system by anverliedoit.
the class ActivityServiceImpl method getActivityList.
@Override
public List<Activity> getActivityList() throws GradingFactorException {
final List<Activity> activityList = new ArrayList<>();
try {
return new AsyncTask<String, List<Activity>, List<Activity>>() {
@Override
protected List<Activity> doInBackground(String... args) {
try {
String link = "".concat(domain).concat("/").concat(baseUri).concat("/").concat(payload);
URL url = new URL(link);
Gson gson = new Gson();
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setRequestProperty("Content-Type", "application/json");
httpURLConnection.setRequestProperty("Accept", "application/json");
httpURLConnection.connect();
if (httpURLConnection.getResponseCode() == 200) {
InputStream inputStream = httpURLConnection.getInputStream();
String jsonData = "";
int data;
while ((data = inputStream.read()) != -1) {
jsonData += (char) data;
}
JSONArray jsonArray = new JSONArray(jsonData);
for (int ctr = 0; ctr < jsonArray.length(); ctr++) {
activityList.add(gson.fromJson(jsonArray.get(ctr).toString(), Activity.class));
}
return activityList;
} else if (httpURLConnection.getResponseCode() == 404) {
InputStream inputStream = httpURLConnection.getInputStream();
String jsonData = "";
int data;
while ((data = inputStream.read()) != -1) {
jsonData += (char) data;
}
Message message = gson.fromJson(jsonData, Message.class);
Log.i("ServiceTAG", "Service : Activity");
Log.i("ServiceTAG", "Status : " + message.getStatus());
Log.i("ServiceTAG", "Type : " + message.getType());
Log.i("ServiceTAG", "Message : " + message.getMessage());
return activityList;
} else
throw new GradingFactorException("Server Error");
} catch (GradingFactorException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
}.execute((String) null).get();
} catch (InterruptedException e) {
e.printStackTrace();
return null;
} catch (ExecutionException e) {
e.printStackTrace();
return null;
}
}
use of com.remswork.project.alice.model.Activity in project classify-system by anverliedoit.
the class ActivityServiceImpl method getActivityListByStudentId.
@Override
public List<Activity> getActivityListByStudentId(final long studentId, final long termId) throws GradingFactorException {
final List<Activity> activityList = new ArrayList<>();
try {
return new AsyncTask<String, List<Activity>, List<Activity>>() {
@Override
protected List<Activity> doInBackground(String... args) {
try {
String link = "".concat(domain).concat("/").concat(baseUri).concat("/").concat(payload).concat("?studentId=").concat(String.valueOf(studentId)).concat("&termId=").concat(String.valueOf(termId));
URL url = new URL(link);
Gson gson = new Gson();
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setRequestProperty("Content-Type", "application/json");
httpURLConnection.setRequestProperty("Accept", "application/json");
httpURLConnection.connect();
if (httpURLConnection.getResponseCode() == 200) {
InputStream inputStream = httpURLConnection.getInputStream();
String jsonData = "";
int data;
while ((data = inputStream.read()) != -1) {
jsonData += (char) data;
}
JSONArray jsonArray = new JSONArray(jsonData);
for (int ctr = 0; ctr < jsonArray.length(); ctr++) {
activityList.add(gson.fromJson(jsonArray.get(ctr).toString(), Activity.class));
}
return activityList;
} else if (httpURLConnection.getResponseCode() == 404) {
InputStream inputStream = httpURLConnection.getInputStream();
String jsonData = "";
int data;
while ((data = inputStream.read()) != -1) {
jsonData += (char) data;
}
Message message = gson.fromJson(jsonData, Message.class);
Log.i("ServiceTAG", "Service : Activity");
Log.i("ServiceTAG", "Status : " + message.getStatus());
Log.i("ServiceTAG", "Type : " + message.getType());
Log.i("ServiceTAG", "Message : " + message.getMessage());
return activityList;
} else
throw new GradingFactorException("Server Error");
} catch (GradingFactorException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
}.execute((String) null).get();
} catch (InterruptedException e) {
e.printStackTrace();
return null;
} catch (ExecutionException e) {
e.printStackTrace();
return null;
}
}
use of com.remswork.project.alice.model.Activity in project classify-system by anverliedoit.
the class ActivityResource method deleteActivityById.
@DELETE
@Path("{activityId}")
public Response deleteActivityById(@PathParam("activityId") long id) {
try {
ActivityResourceLinks resourceLinks = new ActivityResourceLinks(uriInfo);
ClassResourceLinks classResourceLinks = new ClassResourceLinks(uriInfo);
Activity activity = activityService.deleteActivityById(id);
activity.addLink(resourceLinks.self(activity.getId()));
if (activity.get_class() != null)
activity.get_class().addLink(classResourceLinks.self(activity.get_class().getId()));
return Response.status(Response.Status.OK).entity(activity).build();
} catch (GradingFactorException e) {
e.printStackTrace();
Message message = new Message(400, "Bad Request", e.getMessage());
return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
}
}
Aggregations