use of com.dexels.navajo.dependency.Dependency in project navajo by Dexels.
the class BundleCreatorComponent method createBundleForScript.
private void createBundleForScript(String script, String rpcName, File scriptFile, Collection<String> ignoreTenants, boolean isGenericVersion, List<String> failures, List<String> success, List<String> skipped, boolean keepIntermediate) throws CompilationException {
String scriptTenant = tenantFromScriptPath(script);
if (!scriptFile.exists()) {
logger.error("Script or folder not found: {} full path: {}", script, scriptFile.getAbsolutePath());
return;
}
// Only do the include dependency check if we're at the generic version of the script
if (isGenericVersion && getScriptCompiler(scriptFile).supportTslDependencies()) {
Set<String> newTenants = new HashSet<>();
depanalyzer.addDependencies(script, scriptFile);
List<Dependency> dependencies = depanalyzer.getDependencies(script, Dependency.INCLUDE_DEPENDENCY);
if (dependencies != null) {
// If so, compile all versions as if we are tenant-specific (forceTenant), but ignore those tenants that have a tenant-specific version of the original script
for (Dependency d : dependencies) {
if (d.isTentantSpecificDependee() && !ignoreTenants.contains(d.getTentantDependee())) {
newTenants.add(d.getTentantDependee());
}
}
for (String newTenant : newTenants) {
compileAndCreateBundle(script, scriptFile, newTenant, false, true, keepIntermediate, success, skipped, failures);
}
}
if (isGenericVersion) {
// We are not tenant-specific, but check whether we used to have any includes that
// were tenant-specific, that furthermore no longer exist in the new version.
// If so, those must be removed.
uninstallObsoleteTenantScript(rpcName, newTenants);
}
}
compileAndCreateBundle(script, scriptFile, scriptTenant, !isGenericVersion, false, keepIntermediate, success, skipped, failures);
}
use of com.dexels.navajo.dependency.Dependency in project navajo by Dexels.
the class BundleQueueComponent method enqueueDependentScripts.
private void enqueueDependentScripts(String script) {
String rpcName = script;
String bareScript = script.substring(script.lastIndexOf('/') + 1);
if (bareScript.indexOf('_') >= 0) {
rpcName = script.substring(0, script.lastIndexOf('_'));
}
List<Dependency> dependencies = depanalyzer.getReverseDependencies(rpcName);
// Going to pretend all the scripts that include us, also changed. This triggers their
// re-compile, so that they have the correct version. This goes recursive, to allow
// handling includes within includes within includes etc. Use a History set to prevent
// a loop somewhere.
// Use a set to prevent duplicates due to tenant-specific dependencies
Set<String> dependentScripts = new HashSet<>();
for (Dependency dep : dependencies) {
if (dep.getType() == Dependency.INCLUDE_DEPENDENCY || dep.getType() == Dependency.ENTITY_DEPENDENCY) {
dependentScripts.add(dep.getScript());
}
}
for (String depScript : dependentScripts) {
logger.info("Going to recompile {} after a change in {}", depScript, script);
// recursion happens in enqueuescript after installing the bundle.
// This is important, because dependencies only exist after installing
enqueueScript(depScript, null);
}
}
use of com.dexels.navajo.dependency.Dependency in project navajo by Dexels.
the class BundleQueueComponent method ensureScriptDependencies.
// ensure that dependencies of the current script are satisfied. If dependencies
// are not satisfied, create them
private void ensureScriptDependencies(String script) {
String rpcName = script;
String bareScript = script.substring(script.lastIndexOf('/') + 1);
if (bareScript.indexOf('_') >= 0) {
rpcName = script.substring(0, script.lastIndexOf('_'));
}
// For now, only entity dependencies are relevant script dependencies.
// For instance, in the case the server runs in DEVELOP_MODE where
// entities are lazily loaded, all bundles for super entities also need
// to be installed
List<Dependency> dependencies = depanalyzer.getDependencies(rpcName, Dependency.ENTITY_DEPENDENCY);
for (Dependency dependency : dependencies) {
String depScript = dependency.getDependee();
try {
// do an on demand call to the bundle creator, we only need the script to be
// compiled, if it wasn't there yet
bundleCreator.getOnDemandScriptService(depScript, null);
ensureScriptDependencies(depScript);
} catch (CompilationException e) {
logger.info("Failed to compile {} after a change in {}: {}", depScript, script, e);
}
}
}
Aggregations