in services/tenant-service/src/main/java/com/amazon/aws/partners/saasfactory/saasboost/TenantServiceDAL.java [356:461]
public static Tenant fromAttributeValueMap(Map<String, AttributeValue> item) {
Tenant tenant = null;
if (item != null && !item.isEmpty()) {
tenant = new Tenant();
if (item.containsKey("id")) {
try {
tenant.setId(UUID.fromString(item.get("id").s()));
} catch (IllegalArgumentException e) {
LOGGER.error("Failed to parse UUID from database: " + item.get("id").s());
LOGGER.error(Utils.getFullStackTrace(e));
}
}
if (item.containsKey("created")) {
try {
LocalDateTime created = LocalDateTime.parse(item.get("created").s(), DateTimeFormatter.ISO_DATE_TIME);
tenant.setCreated(created);
} catch (DateTimeParseException e) {
LOGGER.error("Failed to parse created date from database: " + item.get("created").s());
LOGGER.error(Utils.getFullStackTrace(e));
}
}
if (item.containsKey("modified")) {
try {
LocalDateTime modified = LocalDateTime.parse(item.get("modified").s(), DateTimeFormatter.ISO_DATE_TIME);
tenant.setModified(modified);
} catch (DateTimeParseException e) {
LOGGER.error("Failed to parse created date from database: " + item.get("modified").s());
LOGGER.error(Utils.getFullStackTrace(e));
}
}
if (item.containsKey("active")) {
tenant.setActive(item.get("active").bool());
}
if (item.containsKey("onboarding")) {
tenant.setOnboardingStatus(item.get("onboarding").s());
}
if (item.containsKey("name")) {
tenant.setName(item.get("name").s());
}
if (item.containsKey("subdomain")) {
tenant.setSubdomain(item.get("subdomain").s());
}
if (item.containsKey("overrideDefaults")) {
tenant.setOverrideDefaults(item.get("overrideDefaults").bool());
}
if (Boolean.TRUE == tenant.getOverrideDefaults()) {
if (item.containsKey("computeSize")) {
tenant.setComputeSize(item.get("computeSize").s());
}
if (item.containsKey("memory")) {
try {
Integer memory = Integer.valueOf(item.get("memory").n());
tenant.setMemory(memory);
} catch (NumberFormatException nfe) {
LOGGER.error("Failed to parse memory from database: {}", item.get("memory").n());
LOGGER.error(Utils.getFullStackTrace(nfe));
}
}
if (item.containsKey("cpu")) {
try {
Integer cpu = Integer.valueOf(item.get("cpu").n());
tenant.setCpu(cpu);
} catch (NumberFormatException nfe) {
LOGGER.error("Failed to parse CPU from database: {}", item.get("cpu").n());
LOGGER.error(Utils.getFullStackTrace(nfe));
}
}
if (item.containsKey("minCount")) {
try {
Integer minCount = Integer.valueOf(item.get("minCount").n());
tenant.setMinCount(minCount);
} catch (NumberFormatException nfe) {
LOGGER.error("Failed to parse min task count from database: {}", item.get("minCount").n());
LOGGER.error(Utils.getFullStackTrace(nfe));
}
}
if (item.containsKey("maxCount")) {
try {
Integer maxCount = Integer.valueOf(item.get("maxCount").n());
tenant.setMaxCount(maxCount);
} catch (NumberFormatException nfe) {
LOGGER.error("Failed to parse max task count from database: {}", item.get("maxCount").n());
LOGGER.error(Utils.getFullStackTrace(nfe));
}
}
}
if (item.containsKey("planId")) {
tenant.setPlanId(item.get("planId").s());
}
if (item.containsKey("resources")) {
try {
tenant.setResources(item.get("resources").m().entrySet()
.stream()
.collect(Collectors.toMap(
entry -> entry.getKey(),
entry -> entry.getValue().s()
))
);
} catch (Exception e) {
LOGGER.error("Failed to parse resources from database: {}", item.get("resources").m());
LOGGER.error(Utils.getFullStackTrace(e));
}
}
}
return tenant;
}