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,241 @@
|
||||
package com.midm.model;
|
||||
|
||||
import com.mitac.cell.db.DbObject;
|
||||
import com.mitac.cell.utils.McBooleanUtils;
|
||||
import com.mitac.cell.utils.McDateTimeUtils;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import org.bson.Document;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
|
||||
public class GeneralProfile {
|
||||
@Id
|
||||
protected UUID uuid;
|
||||
protected DbObject profile;
|
||||
protected DbObject settings;
|
||||
protected Date created;
|
||||
@Indexed
|
||||
protected Date updated;
|
||||
protected Boolean enabled;
|
||||
|
||||
public void init() {
|
||||
this.generateId();
|
||||
this.created = new Date();
|
||||
this.updated = this.created;
|
||||
}
|
||||
|
||||
public void generateId() {
|
||||
this.uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public void setUuid(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public DbObject getProfile() {
|
||||
if (this.profile == null) {
|
||||
this.profile = new DbObject();
|
||||
}
|
||||
|
||||
return this.profile;
|
||||
}
|
||||
|
||||
public void setProfile(DbObject profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public DbObject getSettings() {
|
||||
if (this.settings == null) {
|
||||
this.settings = new DbObject();
|
||||
}
|
||||
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
public void setSettings(DbObject settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return this.created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public Date getUpdated() {
|
||||
return this.updated;
|
||||
}
|
||||
|
||||
public void setUpdated(Date updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
|
||||
public void setUpdated() {
|
||||
this.setUpdated(new Date());
|
||||
}
|
||||
|
||||
public boolean getEnabled() {
|
||||
return this.enabled != null && this.enabled;
|
||||
}
|
||||
|
||||
public boolean isEnded() {
|
||||
if ("ends".equals(this.getProfile("endsOption"))) {
|
||||
DateTime dateTime = McDateTimeUtils.parseDate((String)this.getProfile("ends"), "yyyy-MM-dd").plusDays(1);
|
||||
return dateTime.isBeforeNow();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setEnabled(Boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public Object getProfile(String key) {
|
||||
return this.getProfile(key, (Object)null);
|
||||
}
|
||||
|
||||
public Object getProfile(String key, Object defaultValue) {
|
||||
if (this.getProfile().containsKey(key)) {
|
||||
try {
|
||||
return this.getProfile().get(key);
|
||||
} catch (Exception var4) {
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public boolean getProfileAsBoolean(String category, String key, String subCategory, String item, boolean def) {
|
||||
Boolean value = McBooleanUtils.isTrue(this.getProfile(category, key, subCategory, item));
|
||||
return value == null ? def : value;
|
||||
}
|
||||
|
||||
public Object getProfile(String category, String key, String subCategory, String item) {
|
||||
return this.getProfileCategory(category, key, subCategory).get(item);
|
||||
}
|
||||
|
||||
public DbObject getProfileCategory(String... categoryNames) {
|
||||
return this.getProfile().getDbObject(categoryNames);
|
||||
}
|
||||
|
||||
public Object getCategoryProfile(String category, String key) {
|
||||
return this.getProfileCategory(category) == null ? null : this.getProfileCategory(category).get(key);
|
||||
}
|
||||
|
||||
public void setProfile(String key, Object value) {
|
||||
this.getProfile().put(key, value);
|
||||
}
|
||||
|
||||
public void setProfile(String category, String key, Object value) {
|
||||
this.getProfileCategory(category).put(key, value);
|
||||
}
|
||||
|
||||
public void setProfile(String category, String subCategory, String item, String key, Object value) {
|
||||
this.getProfileCategory(category, subCategory, item).put(key, value);
|
||||
}
|
||||
|
||||
public void removeProfile(String key) {
|
||||
if (this.profile != null) {
|
||||
this.profile.remove(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Object getSetting(String key) {
|
||||
return this.getSettings().get(key);
|
||||
}
|
||||
|
||||
public String getSettingAsString(String key) {
|
||||
return this.getSettings().getString(key, (String)null);
|
||||
}
|
||||
|
||||
public int getSettingAsInt(String key, int def) {
|
||||
return this.getSettings().getInteger(key, def);
|
||||
}
|
||||
|
||||
public float getSettingAsFloat(String key, float def) {
|
||||
return this.getSettings().getFloat(key, def);
|
||||
}
|
||||
|
||||
public boolean getSettingAsBoolean(String key) {
|
||||
return this.getSettingAsBoolean(key, false);
|
||||
}
|
||||
|
||||
public boolean getSettingAsBoolean(String key, boolean def) {
|
||||
return this.getSettings().containsKey(key) ? McBooleanUtils.isTrue(this.getSetting(key)) : def;
|
||||
}
|
||||
|
||||
public boolean getSettingAsBoolean(String category, String key, boolean def) {
|
||||
Boolean value = McBooleanUtils.isTrue(this.getSetting(category, key));
|
||||
return value == null ? def : value;
|
||||
}
|
||||
|
||||
public UUID getSettingAsUuid(String key) {
|
||||
return this.getSettings().getUuid(key);
|
||||
}
|
||||
|
||||
public DbObject getSettingsCategory(String... categoryNames) {
|
||||
return this.getSettings().getDbObject(categoryNames);
|
||||
}
|
||||
|
||||
public Object getSetting(String category, String key) {
|
||||
return this.getSettingsCategory(category).get(key);
|
||||
}
|
||||
|
||||
public void setSetting(String key, UUID value) {
|
||||
if (value != null) {
|
||||
this.getSettings().put(key, value.toString());
|
||||
} else {
|
||||
this.getSettings().remove(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setSetting(String key, Object value) {
|
||||
this.getSettings().put(key, value);
|
||||
}
|
||||
|
||||
public void setSetting(String categoryName, String key, Object value) {
|
||||
Document dbObject = this.getSettingsCategory(categoryName);
|
||||
if (value != null) {
|
||||
dbObject.put(key, value);
|
||||
} else {
|
||||
dbObject.remove(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void removeOption(String key) {
|
||||
this.getSettings().remove(key);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
Object value = this.getProfile("name");
|
||||
return value == null ? null : (String)value;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.setProfile("name", name);
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return (String)this.getProfile("desc");
|
||||
}
|
||||
|
||||
public void setDescription(String desc) {
|
||||
this.setProfile("desc", desc);
|
||||
}
|
||||
|
||||
public void minify() {
|
||||
this.created = null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user