Exemplo n.º 1
0
 /** {@inheritDoc} */
 @MethodLog
 public void removeLabelType(AbstractStorageLabelType<?> labelType) throws StorageException {
   try {
     storageLabelDataDao.removeLabelType(labelType);
   } catch (Exception e) {
     throw new StorageException("Label type was not removed", e);
   }
 }
Exemplo n.º 2
0
 /** {@inheritDoc} */
 @MethodLog
 public void removeLabelsFromCmr(
     Collection<AbstractStorageLabel<?>> storageLabels, boolean removeFromStoragesAlso)
     throws StorageException {
   storageLabelDataDao.removeLabels(storageLabels);
   if (removeFromStoragesAlso) {
     for (StorageData storageData : getExistingStorages()) {
       removeLabelsFromStorage(storageData, new ArrayList<AbstractStorageLabel<?>>(storageLabels));
     }
   }
 }
Exemplo n.º 3
0
 /** {@inheritDoc} */
 @MethodLog
 public void removeLabelFromCmr(
     AbstractStorageLabel<?> storageLabel, boolean removeFromStoragesAlso)
     throws StorageException {
   storageLabelDataDao.removeLabel(storageLabel);
   if (removeFromStoragesAlso) {
     for (StorageData storageData : getExistingStorages()) {
       removeLabelFromStorage(storageData, storageLabel);
     }
   }
 }
Exemplo n.º 4
0
 /** {@inheritDoc} */
 @MethodLog
 public StorageData addLabelToStorage(
     StorageData storageData, AbstractStorageLabel<?> storageLabel, boolean doOverwrite)
     throws StorageException {
   try {
     storageManager.addLabelToStorage(storageData, storageLabel, doOverwrite);
     storageLabelDataDao.saveLabel(storageLabel);
     return storageManager.getStorageData(storageData.getId());
   } catch (IOException | SerializationException e) {
     throw new StorageException(
         "Exception occurred trying to save storage data changes to disk.", e);
   }
 }
Exemplo n.º 5
0
  /**
   * Copies the content of the current CMR buffer to the Storage.
   *
   * @param storageData Storage to copy data to.
   * @param platformIdents List of agent IDs.
   * @param dataProcessors Processors that will be used for data writing.
   * @param autoFinalize If the storage where action is performed should be auto-finalized after the
   *     write.
   * @throws BusinessException If storage is used as a recording storage.
   * @throws SerializationException If storage needs to be created, and serialization fails.
   * @throws IOException If IO exception occurs.
   */
  public void copyBufferToStorage(
      StorageData storageData,
      List<Long> platformIdents,
      Collection<AbstractDataProcessor> dataProcessors,
      boolean autoFinalize)
      throws BusinessException, IOException, SerializationException {
    if (!isStorageExisting(storageData)) {
      this.createStorage(storageData);
    }
    StorageData local = getLocalStorageDataObject(storageData);
    if (!isStorageOpen(local)) {
      this.openStorage(local);
    }

    DefaultData oldestBufferElement = buffer.getOldestElement();
    // only copy if we have smth in the buffer
    if (null != oldestBufferElement) {

      // oldest date is the buffer oldest date, we don't include data from before
      Date fromDate = new Date(oldestBufferElement.getTimeStamp().getTime());
      Date toDate = null;

      // check if we have the time-frame limit
      for (AbstractDataProcessor dataProcessor : dataProcessors) {
        if (dataProcessor instanceof TimeFrameDataProcessor) {
          TimeFrameDataProcessor timeFrameDataProcessor = (TimeFrameDataProcessor) dataProcessor;
          // update dates
          if (timeFrameDataProcessor.getFromDate().after(fromDate)) {
            fromDate = timeFrameDataProcessor.getFromDate();
          }
          toDate = timeFrameDataProcessor.getToDate();
          break;
        }
      }

      for (Long platformId : platformIdents) {
        List<DefaultData> toWriteList =
            storageDataDao.getAllDefaultDataForAgent(platformId.longValue(), fromDate, toDate);
        this.writeToStorage(local, toWriteList, dataProcessors, true);
      }
    }

    if (autoFinalize) {
      this.closeStorage(local);
    }
    updateExistingStorageSize(local);
  }
Exemplo n.º 6
0
  /**
   * Copies set of template data to storage. The storage does not have to be opened before action
   * can be executed (storage will be created/opened first in this case)
   *
   * @param storageData {@link StorageData} to copy to.
   * @param elementIds IDs of the elements to be saved.
   * @param platformIdent Platform ident elements belong to.
   * @param dataProcessors Processors to process the data. Can be null, then the data is only copied
   *     with no processing.
   * @param autoFinalize If the storage where action is performed should be auto-finalized after the
   *     write.
   * @throws IOException If {@link IOException} occurs.
   * @throws SerializationException If serialization fails when storage needs to be created/opened.
   * @throws BusinessException If {@link BusinessException} occurs.
   */
  public void copyDataToStorage(
      StorageData storageData,
      Collection<Long> elementIds,
      long platformIdent,
      Collection<AbstractDataProcessor> dataProcessors,
      boolean autoFinalize)
      throws IOException, SerializationException, BusinessException {
    if (!isStorageExisting(storageData)) {
      this.createStorage(storageData);
    }
    StorageData local = getLocalStorageDataObject(storageData);
    if (!isStorageOpen(local)) {
      this.openStorage(local);
    }

    List<DefaultData> toWriteList = storageDataDao.getDataFromIdList(elementIds, platformIdent);
    this.writeToStorage(local, toWriteList, dataProcessors, true);
    if (autoFinalize) {
      this.closeStorage(local);
    }
    updateExistingStorageSize(local);
  }
Exemplo n.º 7
0
 /** {@inheritDoc} */
 @MethodLog
 public List<AbstractStorageLabelType<?>> getAllLabelTypes() {
   return storageLabelDataDao.getAllLabelTypes();
 }
Exemplo n.º 8
0
 /** {@inheritDoc} */
 @MethodLog
 public <E extends AbstractStorageLabelType<?>> List<E> getLabelTypes(Class<E> labelTypeClass) {
   return storageLabelDataDao.getLabelTypes(labelTypeClass);
 }
Exemplo n.º 9
0
 /** {@inheritDoc} */
 @MethodLog
 public void saveLabelType(AbstractStorageLabelType<?> labelType) {
   storageLabelDataDao.saveLabelType(labelType);
 }
Exemplo n.º 10
0
 /** {@inheritDoc} */
 @MethodLog
 public void saveLabelsToCmr(Collection<AbstractStorageLabel<?>> storageLabels) {
   for (AbstractStorageLabel<?> label : storageLabels) {
     storageLabelDataDao.saveLabel(label);
   }
 }
Exemplo n.º 11
0
 /** {@inheritDoc} */
 @MethodLog
 public void saveLabelToCmr(AbstractStorageLabel<?> storageLabel) {
   storageLabelDataDao.saveLabel(storageLabel);
 }
Exemplo n.º 12
0
 /** {@inheritDoc} */
 @MethodLog
 public <E> List<AbstractStorageLabel<E>> getLabelSuggestions(
     AbstractStorageLabelType<E> labeltype) {
   List<AbstractStorageLabel<E>> results = storageLabelDataDao.getAllLabelsForType(labeltype);
   return results;
 }