Search in sources :

Example 16 with TenantModuleDescriptor

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;
}
Also used : TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor) ModuleDescriptor(org.folio.okapi.bean.ModuleDescriptor) TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor) LinkedList(java.util.LinkedList) InterfaceDescriptor(org.folio.okapi.bean.InterfaceDescriptor)

Example 17 with TenantModuleDescriptor

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);
}
Also used : ModuleDescriptor(org.folio.okapi.bean.ModuleDescriptor) TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) InterfaceDescriptor(org.folio.okapi.bean.InterfaceDescriptor)

Aggregations

TenantModuleDescriptor (org.folio.okapi.bean.TenantModuleDescriptor)17 ModuleDescriptor (org.folio.okapi.bean.ModuleDescriptor)9 LinkedList (java.util.LinkedList)4 InterfaceDescriptor (org.folio.okapi.bean.InterfaceDescriptor)4 DecodeException (io.vertx.core.json.DecodeException)3 Failure (org.folio.okapi.common.Failure)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Tenant (org.folio.okapi.bean.Tenant)2 ModuleId (org.folio.okapi.common.ModuleId)2 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TenantInstallOptions (org.folio.okapi.util.TenantInstallOptions)1