mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-08 20:12:23 +00:00
fixed MDI further
This commit is contained in:
1 parent
6551072e5e
commit
84d183a65f
2 files changed
+25
-5
No files matched your search
+5
-4
@@ -7,6 +7,7 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.domain.base.Boat;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.CompetitorAndBoatStore;
|
||||
import com.sap.sailing.domain.base.DomainFactory;
|
||||
@@ -29,7 +30,7 @@ import com.sap.sse.util.ObjectInputStreamResolvingAgainstCache;
|
||||
import com.sap.sse.util.ObjectInputStreamResolvingAgainstCache.ResolveListener;
|
||||
|
||||
public class MasterDataImporter {
|
||||
private final static Logger LOG = Logger.getLogger(MasterDataImporter.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(MasterDataImporter.class.getName());
|
||||
private final DomainFactory baseDomainFactory;
|
||||
private final RacingEventService racingEventService;
|
||||
private final User user;
|
||||
@@ -52,9 +53,9 @@ public class MasterDataImporter {
|
||||
.createObjectInputStreamResolvingAgainstThisFactory(inputStream, new ResolveListener() {
|
||||
@Override
|
||||
public void onNewObject(Object result) {
|
||||
if (result instanceof WithQualifiedObjectIdentifier) {
|
||||
if (result instanceof Boat || result instanceof Competitor) {
|
||||
QualifiedObjectIdentifier id = ((WithQualifiedObjectIdentifier) result).getIdentifier();
|
||||
LOG.info("Adopting " + id + " from Masterdataimport");
|
||||
logger.info("Adopting " + id + " from Masterdataimport");
|
||||
racingEventService.getSecurityService().setOwnershipIfNotSet(id, user, tenant);
|
||||
}
|
||||
}
|
||||
@@ -105,7 +106,7 @@ public class MasterDataImporter {
|
||||
UUID importOperationId, boolean override) {
|
||||
MasterDataImportObjectCreationCountImpl creationCount = new MasterDataImportObjectCreationCountImpl();
|
||||
ImportMasterDataOperation op = new ImportMasterDataOperation(topLevelMasterData, importOperationId, override,
|
||||
creationCount);
|
||||
creationCount, user, tenant);
|
||||
creationCount = racingEventService.apply(op);
|
||||
return creationCount;
|
||||
}
|
||||
|
||||
+20
-1
@@ -68,6 +68,9 @@ import com.sap.sse.common.Timed;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.sap.sse.concurrent.LockUtil;
|
||||
import com.sap.sse.security.SecurityService;
|
||||
import com.sap.sse.security.shared.QualifiedObjectIdentifier;
|
||||
import com.sap.sse.security.shared.impl.User;
|
||||
import com.sap.sse.security.shared.impl.UserGroup;
|
||||
|
||||
public class ImportMasterDataOperation extends
|
||||
AbstractRacingEventServiceOperation<MasterDataImportObjectCreationCountImpl> {
|
||||
@@ -88,13 +91,20 @@ public class ImportMasterDataOperation extends
|
||||
|
||||
private DataImportProgress progress;
|
||||
|
||||
private User user;
|
||||
|
||||
private UserGroup tenant;
|
||||
|
||||
public ImportMasterDataOperation(TopLevelMasterData topLevelMasterData, UUID importOperationId, boolean override,
|
||||
MasterDataImportObjectCreationCountImpl existingCreationCount) {
|
||||
MasterDataImportObjectCreationCountImpl existingCreationCount, User user, UserGroup tenant) {
|
||||
|
||||
this.creationCount = new MasterDataImportObjectCreationCountImpl();
|
||||
this.creationCount.add(existingCreationCount);
|
||||
this.masterData = topLevelMasterData;
|
||||
this.override = override;
|
||||
this.importOperationId = importOperationId;
|
||||
this.user = user;
|
||||
this.tenant = tenant;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -266,6 +276,7 @@ public class ImportMasterDataOperation extends
|
||||
toState.addLeaderboard(leaderboard);
|
||||
storeRaceLogEvents(leaderboard, toState.getMongoObjectFactory(), toState.getDomainObjectFactory(), override);
|
||||
storeRegattaLogEvents(leaderboard, toState.getMongoObjectFactory(), toState.getDomainObjectFactory(), override);
|
||||
ensureOwnership(leaderboard.getIdentifier(), securityService);
|
||||
creationCount.addOneLeaderboard(leaderboard.getName());
|
||||
relinkTrackedRacesIfPossible(toState, leaderboard);
|
||||
toState.updateStoredLeaderboard(leaderboard);
|
||||
@@ -283,6 +294,7 @@ public class ImportMasterDataOperation extends
|
||||
if (existingLeaderboardGroup == null) {
|
||||
toState.addLeaderboardGroupWithoutReplication(leaderboardGroup);
|
||||
creationCount.addOneLeaderboardGroup(leaderboardGroup.getName());
|
||||
ensureOwnership(leaderboardGroup.getIdentifier(), securityService);
|
||||
} else {
|
||||
logger.info(String.format("Leaderboard Group with name %1$s already exists and hasn't been overridden.",
|
||||
leaderboardGroup.getName()));
|
||||
@@ -529,6 +541,7 @@ public class ImportMasterDataOperation extends
|
||||
}
|
||||
}
|
||||
regatta.getRegattaLog().lockForRead();
|
||||
ensureOwnership(regatta.getIdentifier(), securityService);
|
||||
creationCount.addOneRegatta(regatta.getId().toString());
|
||||
}
|
||||
}
|
||||
@@ -549,6 +562,7 @@ public class ImportMasterDataOperation extends
|
||||
}
|
||||
if (existingEvent == null) {
|
||||
toState.addEventWithoutReplication(event);
|
||||
ensureOwnership(event.getIdentifier(), securityService);
|
||||
creationCount.addOneEvent(event.getId().toString());
|
||||
} else {
|
||||
logger.info(String.format("Event with name %1$s already exists and hasn't been overridden.",
|
||||
@@ -557,6 +571,11 @@ public class ImportMasterDataOperation extends
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureOwnership(QualifiedObjectIdentifier identifier, SecurityService securityService) {
|
||||
logger.info("Adopting " + identifier + " from Masterdataimport");
|
||||
securityService.setOwnershipIfNotSet(identifier, user, tenant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformClientOp(RacingEventServiceOperation<?> serverOp) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Reference in new issue
Block a user