public R getHistoryFactory(String id) { return dataStorage.getHistoryFactory(id); }
public Collection<StoredDataMetadata<S>> getHistoryFactoryList() { return dataStorage.getHistoryFactoryList(); }
private R getPreviousHistoryFactory(String id) { return dataStorage.getPreviousHistoryFactory(id); }
/** * prepare a new factory which could be used to update data. mainly give it the correct baseVersionId * @return new possible factory update with prepared ids/metadata * */ default DataAndNewMetadata<R> prepareNewFactory(){ return prepareNewFactory(getCurrentFactoryStorageId(),getCurrentFactory().root.utility().copy()); }
default R getPreviousHistoryFactory(String id) { Collection<StoredDataMetadata<S>> historyFactoryList = getHistoryFactoryList(); if (historyFactoryList.isEmpty()) return null; List<StoredDataMetadata> historyFactoryListSorted = historyFactoryList.stream().sorted(Comparator.comparing(h -> h.creationTime)).collect(Collectors.toList()); for (int i=0;i<historyFactoryListSorted.size();i++) { if (historyFactoryListSorted.get(i).id.equals(id) && i-1>=0) { return getHistoryFactory(historyFactoryListSorted.get(i - 1).id); } } return null; }
/** * @return creates a new factory update which is ready for editing mainly assign the right ids * */ public DataAndNewMetadata<R> prepareNewFactory() { return dataStorage.prepareNewFactory(dataStorage.getCurrentFactoryStorageId(),factoryManager.getCurrentFactory().utility().copy()); }
public L start() { dataStorage.loadInitialFactory(); final DataAndStoredMetadata<R,S> currentFactory = dataStorage.getCurrentFactory(); currentFactory.root.internalFactory().setMicroservice(this);//also mind ExceptionResponseAction#reset return factoryManager.start(new RootFactoryWrapper<>(currentFactory.root)); }
public FactoryUpdateLog<R> updateCurrentFactory(DataAndNewMetadata<R> update, String user, String comment, Function<String,Boolean> permissionChecker) { R commonVersion = dataStorage.getHistoryFactory(update.metadata.baseVersionId); FactoryUpdateLog<R> factoryLog = factoryManager.update(commonVersion,update.root, permissionChecker); if (!factoryLog.failedUpdate()&& factoryLog.successfullyMerged()){ DataAndNewMetadata<R> copy = new DataAndNewMetadata<>(factoryManager.getCurrentFactory().internal().copy(),update.metadata); dataStorage.updateCurrentFactory(copy,user,comment,factoryLog.mergeDiffInfo); } return factoryLog; }
public MergeDiffInfo<R> simulateUpdateCurrentFactory(DataAndNewMetadata<R> possibleUpdate, Function<String, Boolean> permissionChecker){ R commonVersion = dataStorage.getHistoryFactory(possibleUpdate.metadata.baseVersionId); return factoryManager.simulateUpdate(commonVersion , possibleUpdate.root, permissionChecker); }