2019-05-29 14:52:00 +02:00
|
|
|
package lu.circl.mispbump.models;
|
2019-05-29 14:04:30 +02:00
|
|
|
|
2019-07-24 12:16:51 +02:00
|
|
|
|
2019-07-24 20:32:13 +02:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
2019-08-22 16:58:50 +02:00
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
2019-07-24 12:16:51 +02:00
|
|
|
|
2019-05-29 14:04:30 +02:00
|
|
|
/**
|
2019-08-22 16:58:50 +02:00
|
|
|
* Class that holds the information needed synchronize two misp instances.
|
2019-05-29 14:04:30 +02:00
|
|
|
*/
|
|
|
|
public class SyncInformation {
|
|
|
|
|
2019-08-22 16:58:50 +02:00
|
|
|
private UUID uuid;
|
|
|
|
private Date date, lastModified;
|
|
|
|
|
|
|
|
private ExchangeInformation remote;
|
|
|
|
private ExchangeInformation local;
|
|
|
|
|
|
|
|
|
|
|
|
public SyncInformation() {
|
|
|
|
uuid = UUID.randomUUID();
|
|
|
|
setSyncDate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public UUID getUuid() {
|
|
|
|
return uuid;
|
|
|
|
}
|
|
|
|
public void setUuid(UUID uuid) {
|
|
|
|
this.uuid = uuid;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Date getLastModified() {
|
|
|
|
return lastModified;
|
|
|
|
}
|
|
|
|
public void setLastModified() {
|
|
|
|
setLastModified(Calendar.getInstance().getTime());
|
|
|
|
}
|
|
|
|
public void setLastModified(Date date) {
|
|
|
|
lastModified = date;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSyncDate() {
|
|
|
|
setSyncDate(Calendar.getInstance().getTime());
|
|
|
|
}
|
|
|
|
public void setSyncDate(Date date) {
|
|
|
|
this.date = date;
|
|
|
|
this.lastModified = date;
|
|
|
|
}
|
|
|
|
public Date getSyncDate() {
|
|
|
|
return date;
|
|
|
|
}
|
|
|
|
private String getSyncDateString() {
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy", Locale.getDefault());
|
|
|
|
return df.format(date);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-22 17:14:25 +02:00
|
|
|
public ExchangeInformation getRemote() {
|
|
|
|
return remote;
|
2019-08-22 16:58:50 +02:00
|
|
|
}
|
2019-08-22 17:14:25 +02:00
|
|
|
public void setRemote(ExchangeInformation remote) {
|
|
|
|
this.remote = remote;
|
2019-08-22 16:58:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public ExchangeInformation getLocal() {
|
|
|
|
return local;
|
|
|
|
}
|
|
|
|
public void setLocal(ExchangeInformation local) {
|
|
|
|
this.local = local;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-24 20:32:13 +02:00
|
|
|
@NonNull
|
2019-06-17 09:49:09 +02:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
2019-08-22 16:58:50 +02:00
|
|
|
return "Sync Information: \n" +
|
|
|
|
"UUID = " + uuid + "\n" +
|
2019-08-22 17:14:25 +02:00
|
|
|
"Sync Date = " + getSyncDateString() + "\n" +
|
|
|
|
remote.toString() +
|
2019-08-22 16:58:50 +02:00
|
|
|
local.toString();
|
2019-06-17 09:49:09 +02:00
|
|
|
}
|
2019-05-29 14:04:30 +02:00
|
|
|
}
|