package foundation.capacity.sight;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
import foundation.dao.ILineLimit;
|
import foundation.data.entity.Entity;
|
import foundation.json.IJSONProvider;
|
import foundation.json.IJSONWriter;
|
|
public class Sight implements IJSONProvider {
|
|
protected String id;
|
protected String code;
|
protected String name;
|
private Map<String, LineLimit> lineLimitBucket;
|
|
public Sight() {
|
lineLimitBucket = new HashMap<String, LineLimit>();
|
}
|
|
public void load(Entity entity) {
|
id = entity.getString("id");
|
code = entity.getString("code");
|
name = entity.getString("name");
|
}
|
|
public void loadOneLimit(LineLimit lineLimit) {
|
String tableName = lineLimit.getTableName();
|
|
if (tableName == null) {
|
return;
|
}
|
|
tableName = tableName.toLowerCase();
|
lineLimitBucket.put(tableName, lineLimit);
|
}
|
|
public ILineLimit getLineLimit(String dataName) {
|
if (dataName == null) {
|
return null;
|
}
|
|
dataName = dataName.toLowerCase();
|
LineLimit result = lineLimitBucket.get(dataName);
|
|
if (result == null) {
|
result = LineLimit.FreeLineLimit;
|
}
|
|
return result;
|
}
|
|
public String getId() {
|
return id;
|
}
|
|
public String getCode() {
|
return code;
|
}
|
|
@Override
|
public void writeJSON(IJSONWriter writer) {
|
writer.beginObject("role");
|
writeJSONBody(writer);
|
writer.endObject();
|
}
|
|
public void writeJSONBody(IJSONWriter writer) {
|
writer.write("id", id);
|
writer.write("code", code);
|
writer.write("name", name);
|
}
|
}
|