use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.
the class ModuleManager method addModuleDependencies.
public int addModuleDependencies(ModuleDescriptor md, Map<String, ModuleDescriptor> modsAvailable, Map<String, ModuleDescriptor> modsEnabled, List<TenantModuleDescriptor> tml) {
int sum = 0;
logger.info("addModuleDependencies " + md.getId());
for (InterfaceDescriptor req : md.getRequiresList()) {
int v = checkInterfaceDependency(req, modsAvailable, modsEnabled, tml);
if (v == -1) {
return v;
}
sum += v;
}
List<ModuleDescriptor> fromModule = new LinkedList<>();
sum += resolveModuleConflicts(md, modsEnabled, tml, fromModule);
logger.info("addModuleDependencies - add " + md.getId());
modsEnabled.put(md.getId(), md);
TenantModuleDescriptor tm = new TenantModuleDescriptor();
tm.setAction("enable");
if (!fromModule.isEmpty()) {
tm.setFrom(fromModule.get(0).getId());
}
tm.setId(md.getId());
tml.add(tm);
return sum + 1;
}
use of org.folio.okapi.bean.TenantModuleDescriptor in project okapi by folio-org.
the class ModuleManager method checkInterfaceDependency.
private int checkInterfaceDependency(InterfaceDescriptor req, Map<String, ModuleDescriptor> modsAvailable, Map<String, ModuleDescriptor> modsEnabled, List<TenantModuleDescriptor> tml) {
logger.info("checkInterfaceDependency1");
for (Map.Entry<String, ModuleDescriptor> entry : modsEnabled.entrySet()) {
ModuleDescriptor md = entry.getValue();
for (InterfaceDescriptor pi : md.getProvidesList()) {
if (req.getId().equals(pi.getId()) && pi.isCompatible(req)) {
logger.debug("Dependency OK");
return 0;
}
}
}
logger.info("checkInterfaceDependency2");
ModuleDescriptor foundMd = null;
for (Map.Entry<String, ModuleDescriptor> entry : modsAvailable.entrySet()) {
ModuleDescriptor md = entry.getValue();
for (InterfaceDescriptor pi : md.getProvidesList()) {
if (req.getId().equals(pi.getId()) && pi.isCompatible(req) && (foundMd == null || md.compareTo(foundMd) > 0)) {
// newest module
foundMd = md;
}
}
}
if (foundMd == null) {
return -1;
}
return addModuleDependencies(foundMd, modsAvailable, modsEnabled, tml);
}
Aggregations