use of cz.o2.proxima.storage.StorageType in project proxima-platform by O2-Czech-Republic.
the class ConfigRepository method loadSingleFamily.
private void loadSingleFamily(String name, boolean overwrite, Map<String, Object> cfg) throws URISyntaxException {
cfg = flatten(cfg);
boolean isDisabled = Optional.ofNullable(cfg.get(DISABLED)).map(Object::toString).map(Boolean::valueOf).orElse(false);
if (isDisabled) {
log.info("Skipping load of disabled family {}", name);
return;
}
final String entity = Objects.requireNonNull(cfg.get(ENTITY)).toString();
final String filter = toString(cfg.get(FILTER));
final boolean isTransactional = entity.equals(TRANSACTION_ENTITY);
final StorageType type = getStorageType(cfg, isTransactional);
final AccessType access = getAccessType(cfg, isTransactional);
final List<String> attributes = toList(Objects.requireNonNull(cfg.get(ATTRIBUTES), () -> String.format("Missing required field `%s' in attributeFamily %s", ATTRIBUTES, name)));
final URI storageUri = new URI(Objects.requireNonNull(cfg.get(STORAGE), () -> String.format("Missing required field `%s' in attribute family %s", STORAGE, name)).toString());
final EntityDescriptor entDesc = findEntityRequired(entity);
AttributeFamilyDescriptor.Builder family = AttributeFamilyDescriptor.newBuilder().setEntity(entDesc).setName(name).setType(type).setAccess(access).setStorageUri(storageUri).setCfg(withTransactionalPartitioner(isTransactional, cfg)).setSource((String) cfg.get(FROM));
Collection<AttributeDescriptor<?>> allAttributes = new HashSet<>();
for (String attr : attributes) {
// attribute descriptors affected by this settings
final List<AttributeDescriptor<?>> attrDescs;
attrDescs = searchAttributesMatching(attr, entDesc, false, false);
allAttributes.addAll(attrDescs);
}
if (!filter.isEmpty() && !readonly) {
insertFilterIfPossible(allAttributes, type, filter, name, family);
}
allAttributes.forEach(family::addAttribute);
insertFamily(family.build(), overwrite);
}
use of cz.o2.proxima.storage.StorageType in project proxima-platform by O2-Czech-Republic.
the class ConfigRepository method getStorageType.
private StorageType getStorageType(Map<String, Object> cfg, boolean isTransactional) {
StorageType type = Optional.ofNullable((String) cfg.get(TYPE)).map(StorageType::of).orElse(isTransactional ? StorageType.PRIMARY : null);
Preconditions.checkArgument(type != null, "Missing required setting %s", TYPE);
return type;
}
Aggregations