feat: complete reverse engineering, standard Maven structure, detailed code annotations and IoT-M platform architecture
This commit is contained in:
1 parent
e8dc09fb3c
commit
cd6a4c70e7
3045 files changed
+566733
-1
No files matched your search
@@ -0,0 +1,155 @@
|
||||
package com.midm.model.device;
|
||||
|
||||
import com.mitac.cell.db.DbObject;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.mongodb.core.index.CompoundIndex;
|
||||
import org.springframework.data.mongodb.core.index.CompoundIndexes;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
@Document
|
||||
@CompoundIndexes({@CompoundIndex(
|
||||
def = "{'_id.deviceUuid': 1}"
|
||||
), @CompoundIndex(
|
||||
def = "{'_id.profileUuid': 1}"
|
||||
)})
|
||||
public class DeviceProfileState {
|
||||
public static final String STATE_IN_PROGRESS = "in_progress";
|
||||
public static final String STATE_DONE = "done";
|
||||
public static final String STATE_UNKNWON = "unknown";
|
||||
@Id
|
||||
private Scoped scoped;
|
||||
private long updated = -1L;
|
||||
@Indexed
|
||||
private String state = "unknown";
|
||||
private String applyFirstState = "unknown";
|
||||
@Indexed
|
||||
private long applied;
|
||||
@Transient
|
||||
private DeviceReport report;
|
||||
|
||||
public DeviceProfileState() {
|
||||
}
|
||||
|
||||
public DeviceProfileState(Device device, DeviceProfile profile) {
|
||||
this.scoped = new Scoped(profile.getUuid(), device.getUuid());
|
||||
this.updated = profile.getUpdated().getTime();
|
||||
this.applied = (new Date()).getTime();
|
||||
}
|
||||
|
||||
public DeviceProfileState(DeviceReport report) {
|
||||
this.setReport(report);
|
||||
}
|
||||
|
||||
public Scoped getScoped() {
|
||||
return this.scoped;
|
||||
}
|
||||
|
||||
public void setScoped(Scoped scoped) {
|
||||
this.scoped = scoped;
|
||||
}
|
||||
|
||||
public UUID getProfileUuid() {
|
||||
return this.getScoped().getProfileUuid();
|
||||
}
|
||||
|
||||
public UUID getDeviceUuid() {
|
||||
return this.getScoped().getDeviceUuid();
|
||||
}
|
||||
|
||||
public long getUpdated() {
|
||||
return this.updated;
|
||||
}
|
||||
|
||||
public void setUpdated(long updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return this.state == null || this.state.equals("done");
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getApplyFirstState() {
|
||||
return this.applyFirstState;
|
||||
}
|
||||
|
||||
public boolean isApplyFirstDone() {
|
||||
return this.applyFirstState != null && this.applyFirstState.equals("done");
|
||||
}
|
||||
|
||||
public void setApplyFirstState(String applyFirstState) {
|
||||
this.applyFirstState = applyFirstState;
|
||||
}
|
||||
|
||||
public long getApplied() {
|
||||
return this.applied;
|
||||
}
|
||||
|
||||
public void setApplied(long applied) {
|
||||
this.applied = applied;
|
||||
this.setState("done");
|
||||
}
|
||||
|
||||
public void setApplied(long applied, String state) {
|
||||
this.state = state;
|
||||
this.applied = applied;
|
||||
}
|
||||
|
||||
public void setApplied() {
|
||||
this.applied = (new Date()).getTime();
|
||||
}
|
||||
|
||||
public DeviceReport getReport() {
|
||||
return this.report;
|
||||
}
|
||||
|
||||
public void setReport(DeviceReport report) {
|
||||
this.report = report;
|
||||
DbObject profile = report.getProperties().getDbObject(new String[]{"deviceProfile"});
|
||||
this.scoped = new Scoped(profile.getUuid("uuid"), report.getDeviceUuid());
|
||||
this.updated = profile.getLong("updated", -1L);
|
||||
this.applied = profile.getLong("applied", -1L);
|
||||
this.setState("done");
|
||||
}
|
||||
|
||||
public static class Scoped implements Serializable {
|
||||
private UUID profileUuid;
|
||||
private UUID deviceUuid;
|
||||
|
||||
public Scoped() {
|
||||
}
|
||||
|
||||
public Scoped(UUID profileUuid, UUID deviceUuid) {
|
||||
this.profileUuid = profileUuid;
|
||||
this.deviceUuid = deviceUuid;
|
||||
}
|
||||
|
||||
public UUID getProfileUuid() {
|
||||
return this.profileUuid;
|
||||
}
|
||||
|
||||
public void setProfileUuid(UUID profileUuid) {
|
||||
this.profileUuid = profileUuid;
|
||||
}
|
||||
|
||||
public UUID getDeviceUuid() {
|
||||
return this.deviceUuid;
|
||||
}
|
||||
|
||||
public void setDeviceUuid(UUID deviceUuid) {
|
||||
this.deviceUuid = deviceUuid;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user