Переглянути джерело

only filter some entities when fullCopy is false

tags/v0.8.0
Jonathan Cobb 4 роки тому
джерело
коміт
75a9688517
3 змінених файлів з 12 додано та 7 видалено
  1. +10
    -5
      bubble-server/src/main/java/bubble/service/dbfilter/EntityIterator.java
  2. +1
    -1
      bubble-server/src/main/java/bubble/service/dbfilter/FilteredEntityIterator.java
  3. +1
    -1
      bubble-server/src/main/java/bubble/service/dbfilter/FullEntityIterator.java

+ 10
- 5
bubble-server/src/main/java/bubble/service/dbfilter/EntityIterator.java Переглянути файл

@@ -77,18 +77,21 @@ public abstract class EntityIterator implements Iterator<Identifiable> {
}
}

public void addEntities(Class<? extends Identifiable> c,
public void addEntities(boolean fullCopy,
Class<? extends Identifiable> c,
List<? extends Identifiable> entities,
BubbleNetwork network,
BubbleNode node,
List<BubblePlanApp> planApps) {
if (CloudService.class.isAssignableFrom(c)) {
entities.forEach(e -> add(setLocalStoragePath((CloudService) e)));
entities.stream()
.filter(cloud -> fullCopy || notPaymentCloud((CloudService) cloud))
.forEach(e -> add(setLocalStoragePath((CloudService) e)));

} else if (AccountSshKey.class.isAssignableFrom(c)) {
entities.forEach(e -> add(setInstallKey((AccountSshKey) e, network)));

} else if (planApps != null && BubbleApp.class.isAssignableFrom(c)) {
} else if (!fullCopy && planApps != null && BubbleApp.class.isAssignableFrom(c)) {
// only copy enabled apps, make them templates
entities.stream().filter(app -> planAppEnabled(((BubbleApp) app).getTemplateApp(), planApps))
.map(app -> ((BubbleApp) app).setTemplate(true))
@@ -97,7 +100,7 @@ public abstract class EntityIterator implements Iterator<Identifiable> {
// save these for later, we will need them when copying BubblePlanApps below
userApps = (List<BubbleApp>) entities;

} else if (planApps != null && BubblePlanApp.class.isAssignableFrom(c)) {
} else if (!fullCopy && planApps != null && BubblePlanApp.class.isAssignableFrom(c)) {
// the only BubblePlanApps we will see here are the ones associated with the system BubblePlans
// and the system/template BubbleApps.
// But for this new node, the BubbleApps that are associated with the first user (admin of new node)
@@ -124,7 +127,7 @@ public abstract class EntityIterator implements Iterator<Identifiable> {
}
}

} else if (planApps != null && AccountTemplate.class.isAssignableFrom(c)) {
} else if (!fullCopy && planApps != null && AccountTemplate.class.isAssignableFrom(c)) {
// only copy app-related entities for enabled apps, make them all templates
entities.stream()
.map(app -> (AccountTemplate) ((AccountTemplate) app).setTemplate(true))
@@ -135,6 +138,8 @@ public abstract class EntityIterator implements Iterator<Identifiable> {
}
}

private boolean notPaymentCloud(CloudService cloud) { return !cloud.getDriverClass().contains(".payment."); }

private boolean planAppEnabled(String appUuid, List<BubblePlanApp> planApps) {
return planApps == null || planApps.stream().anyMatch(planApp -> planApp.getApp().equals(appUuid));
}


+ 1
- 1
bubble-server/src/main/java/bubble/service/dbfilter/FilteredEntityIterator.java Переглянути файл

@@ -80,7 +80,7 @@ public class FilteredEntityIterator extends EntityIterator {
final List<? extends HasAccount> entities = aoDAO.dbFilterIncludeAll()
? aoDAO.findAll()
: aoDAO.findByAccount(account.getUuid());
addEntities(c, entities, network, node, planApps);
addEntities(false, c, entities, network, node, planApps);
}
});



+ 1
- 1
bubble-server/src/main/java/bubble/service/dbfilter/FullEntityIterator.java Переглянути файл

@@ -22,7 +22,7 @@ public class FullEntityIterator extends EntityIterator {

protected void iterate() {
config.getEntityClasses().forEach(c -> {
addEntities(c, config.getDaoForEntityClass(c).findAll(), network, null, null);
addEntities(true, c, config.getDaoForEntityClass(c).findAll(), network, null, null);
});
log.info("iterate: completed");
}


Завантаження…
Відмінити
Зберегти