Search in sources :

Example 11 with InterfaceDescriptor

use of org.folio.okapi.bean.InterfaceDescriptor 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 12 with InterfaceDescriptor

use of org.folio.okapi.bean.InterfaceDescriptor 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

InterfaceDescriptor (org.folio.okapi.bean.InterfaceDescriptor)12 ModuleDescriptor (org.folio.okapi.bean.ModuleDescriptor)7 TenantModuleDescriptor (org.folio.okapi.bean.TenantModuleDescriptor)7 LinkedList (java.util.LinkedList)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ModuleInstance (org.folio.okapi.bean.ModuleInstance)1 PermissionList (org.folio.okapi.bean.PermissionList)1 RoutingEntry (org.folio.okapi.bean.RoutingEntry)1 Tenant (org.folio.okapi.bean.Tenant)1