use of org.activityinfo.server.database.hibernate.entity.IndicatorLinkEntity in project activityinfo by bedatadriven.
the class SchemaUpdateBuilder method createAndSyncIndicatorlinks.
private void createAndSyncIndicatorlinks(JpaUpdateBuilder builder) throws JSONException {
builder.executeStatement("create table if not exists IndicatorLink (SourceIndicatorId int, DestinationIndicatorId int) ");
builder.executeStatement("delete from IndicatorLink");
if (!indicatorLinks.isEmpty()) {
builder.beginPreparedStatement("insert into IndicatorLink (SourceIndicatorId, DestinationIndicatorId) values (?, ?) ");
for (IndicatorLinkEntity il : indicatorLinks) {
builder.addExecution(il.getId().getSourceIndicatorId(), il.getId().getDestinationIndicatorId());
}
builder.finishPreparedStatement();
}
}
use of org.activityinfo.server.database.hibernate.entity.IndicatorLinkEntity in project activityinfo by bedatadriven.
the class SchemaUpdateBuilder method makeEntityLists.
private void makeEntityLists() {
for (UserDatabase database : databases) {
if (!userIds.contains(database.getOwner().getId())) {
User u = database.getOwner();
// don't send hashed password to client
// EEK i think hibernate will persist this to the database
// automatically if we change it here!!
// u.setHashedPassword("");
users.add(u);
userIds.add(u.getId());
}
if (!countryIds.contains(database.getCountry().getId())) {
countries.add(database.getCountry());
adminLevels.addAll(database.getCountry().getAdminLevels());
countryIds.add(database.getCountry().getId());
for (org.activityinfo.server.database.hibernate.entity.LocationType l : database.getCountry().getLocationTypes()) {
locationTypes.add(l);
}
}
for (Partner partner : database.getPartners()) {
if (!partnerIds.contains(partner.getId())) {
partners.add(partner);
partnerIds.add(partner.getId());
}
}
projects.addAll(new ArrayList<Project>(database.getProjects()));
allLockedPeriods.addAll(database.getLockedPeriods());
for (Project project : database.getProjects()) {
allLockedPeriods.addAll(project.getLockedPeriods());
}
for (Activity activity : database.getActivities()) {
allLockedPeriods.addAll(activity.getLockedPeriods());
activities.add(activity);
for (Indicator indicator : activity.getIndicators()) {
indicators.add(indicator);
List<IndicatorLinkEntity> links = findIndicatorLinks(indicator);
if (links != null && !links.isEmpty()) {
indicatorLinks.addAll(links);
}
}
for (AttributeGroup g : activity.getAttributeGroups()) {
if (!attributeGroupIds.contains(g.getId())) {
attributeGroups.add(g);
attributeGroupIds.add(g.getId());
for (Attribute a : g.getAttributes()) {
attributes.add(a);
}
}
}
}
}
}
Aggregations