private void assignResponsableUser(User user) { if (user == null) { return; } ReportItem item = getItem(); if (item == null) { return; } ChangeReportResponsableUserSyncAction action = new ChangeReportResponsableUserSyncAction(item.id, item.category_id, user.id); Zup.getInstance().getSyncActionService().addSyncAction(action); Zup.getInstance().sync(); }
private void assignResponsableGroup(String comment) { if (group == null) { return; } ReportItem item = getItem(); if (item == null) { return; } ChangeReportResponsableGroupSyncAction action = new ChangeReportResponsableGroupSyncAction( item.id, item.category_id, group.getId(), comment); Zup.getInstance().getSyncActionService().addSyncAction(action); Zup.getInstance().sync(); }
private void updateResponsabilityBehavior(ViewGroup root) { ReportCategory category = Zup.getInstance().getReportCategoryService().getReportCategory(getItem().category_id); // boolean hasSolverGroups = category != null && category.solver_groups_ids != null && // category.solver_groups_ids.length > 0; if (Zup.getInstance().getAccess().canForwardReportItems(category.id)) { root.findViewById(R.id.responsable_group_container).setOnClickListener(this); root.findViewById(R.id.responsable_user_container).setOnClickListener(this); root.findViewById(R.id.change_responsable_group).setVisibility(View.VISIBLE); root.findViewById(R.id.change_responsable_user).setVisibility(View.VISIBLE); } else { root.findViewById(R.id.change_responsable_group).setVisibility(View.GONE); root.findViewById(R.id.change_responsable_user).setVisibility(View.GONE); } }
@Override protected JSONObject serialize() throws Exception { Serializer serializer = new Serializer(); serializer.reportId = reportId; serializer.error = getError(); serializer.categoryId = categoryId; serializer.groupId = groupId; serializer.comment = comment; String res = Zup.getInstance().getObjectMapper().writeValueAsString(serializer); return new JSONObject(res); }
@Override protected boolean onPerform() { try { AssignReportToGroupRequest assignReportToGroupRequest = new AssignReportToGroupRequest(); assignReportToGroupRequest.setGroupId(groupId); assignReportToGroupRequest.setComment(comment); SingleReportItemCollection result = Zup.getInstance() .getService() .assignReportToGroup(this.categoryId, reportId, assignReportToGroupRequest); Intent intent = new Intent(); intent.putExtra("report", result.report); broadcastAction(REPORT_RESPONSABLE_GROUP_ASSIGNED, intent); } catch (RetrofitError error) { int errorType = error.getResponse() != null ? error.getResponse().getStatus() : 0; Crashlytics.logException(SyncErrors.build(errorType, error)); setError(error.getMessage()); return false; } return true; }
void fillData(ViewGroup root) { if (getItem() == null) return; ReportItem item = getItem(); ReportCategory category = Zup.getInstance().getReportCategoryService().getReportCategory(item.category_id); ReportCategory.Status status = null; if (item.status_id != -1 && category != null) { status = category.getStatus(item.status_id); } TextView txtProtocol = (TextView) root.findViewById(R.id.protocol); TextView txtAddress = (TextView) root.findViewById(R.id.full_address); TextView txtReference = (TextView) root.findViewById(R.id.reference); TextView txtDescription = (TextView) root.findViewById(R.id.description); TextView txtCategory = (TextView) root.findViewById(R.id.category_name); TextView txtCreation = (TextView) root.findViewById(R.id.creation_date); TextView txtStatus = (TextView) root.findViewById(R.id.status); TextView txtGroup = (TextView) root.findViewById(R.id.responsible_group_name); TextView txtUser = (TextView) root.findViewById(R.id.responsible_user_name); txtProtocol.setText(item.protocol); txtAddress.setText(item.getFullAddress()); txtReference.setText(notInformedIfBlank(item.reference)); txtDescription.setText(notInformedIfBlank(item.description)); txtCategory.setText(category != null ? category.title : ""); txtCreation.setText(Utilities.formatIsoDateAndTime(item.created_at)); if (status != null) txtStatus.setText(status.getTitle()); else txtStatus.setText(R.string.no_status); if (item.assignedUser != null) txtUser.setText(item.assignedUser.name); else txtUser.setText(R.string.no_responsable_user_text); if (item.assignedGroup != null) txtGroup.setText(item.assignedGroup.getName()); else txtGroup.setText(R.string.no_responsable_group_text); updateResponsabilityBehavior(root); }