string to array: restricted_to_domain, getter and setter

pull/5/head
Felix Prahl-Kamps 2019-07-22 14:43:12 +02:00
parent 5e95c53670
commit 592557176a
8 changed files with 146 additions and 33 deletions

View File

@ -289,7 +289,7 @@ public class ExchangeActivity extends AppCompatActivity {
final List<UploadInformation> uploadInformationList = preferenceManager.getUploadInformationList();
for (final UploadInformation ui : uploadInformationList) {
if (ui.getRemote().organisation.uuid.equals(remoteSyncInfo.organisation.uuid)) {
if (ui.getRemote().organisation.getUuid().equals(remoteSyncInfo.organisation.getUuid())) {
DialogManager.syncAlreadyExistsDialog(ui.getRemote(), remoteSyncInfo, ExchangeActivity.this, new DialogManager.IDialogFeedback() {
@Override
public void positive() {

View File

@ -79,23 +79,23 @@ public class ProfileActivity extends AppCompatActivity {
Organisation organisation = preferenceManager.getUserOrganisation();
TextView name = findViewById(R.id.orgName);
name.setText(organisation.name);
name.setText(organisation.getName());
final MaterialPreferenceText uuid = findViewById(R.id.uuid);
uuid.setSubtitle(organisation.uuid);
uuid.setSubtitle(organisation.getUuid());
MaterialPreferenceText nationality = findViewById(R.id.nationality);
nationality.setSubtitle(organisation.nationality);
nationality.setSubtitle(organisation.getNationality());
MaterialPreferenceText sector = findViewById(R.id.sector);
if (organisation.sector == null) {
if (organisation.getSector() == null) {
sector.setVisibility(View.GONE);
} else {
sector.setSubtitle(organisation.sector);
sector.setSubtitle(organisation.getSector());
}
MaterialPreferenceText description = findViewById(R.id.description);
description.setSubtitle(organisation.description);
description.setSubtitle(organisation.getDescription());
}
@Override

View File

@ -212,7 +212,7 @@ public class UploadActivity extends AppCompatActivity {
private User generateSyncUser(Organisation organisation) {
User syncUser = new User();
syncUser.org_id = organisation.id;
syncUser.org_id = organisation.getId();
syncUser.role_id = User.ROLE_SYNC_USER;
syncUser.email = uploadInformation.getRemote().syncUserEmail;
syncUser.password = uploadInformation.getRemote().syncUserPassword;
@ -224,9 +224,9 @@ public class UploadActivity extends AppCompatActivity {
private Server generateSyncServer() {
Server server = new Server();
server.name = uploadInformation.getRemote().organisation.name + "'s Sync Server";
server.name = uploadInformation.getRemote().organisation.getName() + "'s Sync Server";
server.url = uploadInformation.getRemote().baseUrl;
server.remote_org_id = uploadInformation.getRemote().organisation.id;
server.remote_org_id = uploadInformation.getRemote().organisation.getId();
server.authkey = uploadInformation.getLocal().syncUserAuthkey;
server.pull = uploadInformation.isPull();
server.push = uploadInformation.isPush();
@ -256,11 +256,11 @@ public class UploadActivity extends AppCompatActivity {
private void organisationAdded(Organisation organisation) {
if (organisation != null) {
setUploadActionState(orgAction, UploadAction.UploadState.DONE, null);
uploadInformation.getRemote().organisation.id = organisation.id;
uploadInformation.getRemote().organisation.setId(organisation.getId());
restClient.addUser(generateSyncUser(organisation), userCallback);
} else {
// search by UUID because the error does not give the actual ID
restClient.getOrganisation(uploadInformation.getRemote().organisation.uuid, new MispRestClient.OrganisationCallback() {
restClient.getOrganisation(uploadInformation.getRemote().organisation.getUuid(), new MispRestClient.OrganisationCallback() {
@Override
public void success(Organisation organisation) {
organisationAdded(organisation);

View File

@ -127,7 +127,7 @@ public class UploadInfoActivity extends AppCompatActivity {
assert ab != null;
TextView toolbarTitle = findViewById(R.id.toolbarTitle);
toolbarTitle.setText(uploadInformation.getRemote().organisation.name);
toolbarTitle.setText(uploadInformation.getRemote().organisation.getName());
ab.setHomeAsUpIndicator(R.drawable.ic_close);

View File

@ -45,7 +45,7 @@ public class UploadInfoAdapter extends RecyclerView.Adapter<UploadInfoAdapter.Vi
final UploadInformation item = items.get(position);
holder.date.setText(item.getDateString());
holder.orgName.setText(item.getRemote().organisation.name);
holder.orgName.setText(item.getRemote().organisation.getName());
switch (item.getCurrentSyncStatus()) {
case COMPLETE:

View File

@ -26,10 +26,10 @@ public class DialogManager {
// this dialog needs definite user feedback
adb.setCancelable(false);
if (oldSync.organisation.name.equals(newSync.organisation.name)) {
adb.setTitle("Already Synced with " + oldSync.organisation.name);
if (oldSync.organisation.getName().equals(newSync.organisation.getName())) {
adb.setTitle("Already Synced with " + oldSync.organisation.getName());
} else {
adb.setTitle("Already Synced with " + oldSync.organisation.name + "(Now:" + newSync.organisation.name + ")");
adb.setTitle("Already Synced with " + oldSync.organisation.getName() + "(Now:" + newSync.organisation.getName() + ")");
}
adb.setMessage("");
@ -142,7 +142,7 @@ public class DialogManager {
final AlertDialog.Builder adb = new AlertDialog.Builder(context);
adb.setTitle("Sync information received");
adb.setMessage(syncInformation.organisation.name);
adb.setMessage(syncInformation.organisation.getName());
adb.setPositiveButton("Accept", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

View File

@ -355,7 +355,7 @@ public class MispRestClient {
@Override
public void success(Organisation[] organisations) {
for (Organisation organisation : organisations) {
if (organisation.uuid.equals(uuid)) {
if (organisation.getUuid().equals(uuid)) {
callback.success(organisation);
return;
}

View File

@ -5,20 +5,20 @@ package lu.circl.mispbump.models.restModels;
*/
public class Organisation {
public Integer id;
public String name;
public String date_created;
public String date_modified;
public String type;
public String nationality;
public String sector;
public String contacts;
public String description;
public Boolean local;
public String uuid;
public String restricted_to_domain;
public String created_by;
public Integer user_count;
private Integer id;
private String name;
private String date_created;
private String date_modified;
private String type;
private String nationality;
private String sector;
private String contacts;
private String description;
private Boolean local;
private String uuid;
private String[] restricted_to_domain;
private String created_by;
private Integer user_count;
public Organisation() {
}
@ -46,6 +46,119 @@ public class Organisation {
return organisation;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDate_created() {
return date_created;
}
public void setDate_created(String date_created) {
this.date_created = date_created;
}
public String getDate_modified() {
return date_modified;
}
public void setDate_modified(String date_modified) {
this.date_modified = date_modified;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getNationality() {
return nationality;
}
public void setNationality(String nationality) {
this.nationality = nationality;
}
public String getSector() {
return sector;
}
public void setSector(String sector) {
this.sector = sector;
}
public String getContacts() {
return contacts;
}
public void setContacts(String contacts) {
this.contacts = contacts;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Boolean getLocal() {
return local;
}
public void setLocal(Boolean local) {
this.local = local;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String[] getRestricted_to_domain() {
return restricted_to_domain;
}
public void setRestricted_to_domain(String[] restricted_to_domain) {
this.restricted_to_domain = restricted_to_domain;
}
public String getCreated_by() {
return created_by;
}
public void setCreated_by(String created_by) {
this.created_by = created_by;
}
public Integer getUser_count() {
return user_count;
}
public void setUser_count(Integer user_count) {
this.user_count = user_count;
}
@Override
public String toString() {
return "Organisation{" +