Class ModelCopyManager

java.lang.Object
org.spdx.library.ModelCopyManager
All Implemented Interfaces:
org.spdx.core.IModelCopyManager

public class ModelCopyManager extends Object implements org.spdx.core.IModelCopyManager
This class helps facilitate copying objects from one model to another.

In addition to the copy functions (methods), this object keeps track of what was copied where so that the same object is not copied twice.

This object can be passed into the constructor for ModelObjects to allow the objects to be copied.

Author:
Gary O'Neall
  • Constructor Details

    • ModelCopyManager

      public ModelCopyManager()
      Create a ModelCopyManager with default options
  • Method Details

    • versionsCompatible

      public boolean versionsCompatible(String fromSpecVersion, String toSpecVersion)
      Parameters:
      fromSpecVersion - from spec version
      toSpecVersion - to spec version
      Returns:
      true if no conversion is needed from the fromSpecVersion to the toSpecVersion
    • canConvert

      public boolean canConvert(String fromSpecVersion, String toSpecVersion)
      Parameters:
      fromSpecVersion - from spec version
      toSpecVersion - to spec version
      Returns:
      true if the fromSpecVersion can be converted to the toSpecVersion
    • getCopiedObjectUri

      @Nullable public String getCopiedObjectUri(org.spdx.storage.IModelStore fromStore, String fromObjectUri, org.spdx.storage.IModelStore toStore)
      Specified by:
      getCopiedObjectUri in interface org.spdx.core.IModelCopyManager
      Parameters:
      fromStore - Store copied from
      fromObjectUri - Object URI in the fromStore
      toStore - store copied to
      Returns:
      the objectId which has already been copied, or null if it has not been copied
    • getSpecConverter

      @Nullable public ISpdxConverter getSpecConverter(org.spdx.storage.IModelStore fromStore, org.spdx.storage.IModelStore toStore, String fromSpecVersion, String toSpecVersion, boolean create) throws org.spdx.core.InvalidSPDXAnalysisException
      Parameters:
      fromStore - store converting from
      toStore - store converting to
      fromSpecVersion - spec version converting from
      toSpecVersion - spec version converting to
      create - if true, create the spec converter if it does not already exist
      Returns:
      a converter for the fromStore fromSpecVersion to the toStore toSpecVersion
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException - On SPDX parsing errors
    • putCopiedId

      public String putCopiedId(org.spdx.storage.IModelStore fromStore, String fromObjectUri, org.spdx.storage.IModelStore toStore, String toObjectUri)
      Record a copied ID between model stores
      Specified by:
      putCopiedId in interface org.spdx.core.IModelCopyManager
      Parameters:
      fromStore - Store copied from
      fromObjectUri - URI for the from Object
      toObjectUri - URI for the to Object
      Returns:
      any copied to ID for the same stores, URI's, nameSpace and fromID
    • copy

      public void copy(org.spdx.storage.IModelStore toStore, String toObjectUri, org.spdx.storage.IModelStore fromStore, String fromObjectUri, String toSpecVersion, @Nullable String toNamespace) throws org.spdx.core.InvalidSPDXAnalysisException
      Specified by:
      copy in interface org.spdx.core.IModelCopyManager
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException
    • copy

      public org.spdx.core.TypedValue copy(org.spdx.storage.IModelStore toStore, org.spdx.storage.IModelStore fromStore, String sourceUri, String toSpecVersion, @Nullable String toNamespace) throws org.spdx.core.InvalidSPDXAnalysisException
      Copy an item from one Model Object Store to another using the source ID for the target unless it is anonymous
      Specified by:
      copy in interface org.spdx.core.IModelCopyManager
      Parameters:
      toStore - Model Store to copy to
      fromStore - Model Store containing the source item
      sourceUri - URI for the Source object
      toSpecVersion - Version of the SPDX spec the to value complies with
      toNamespace - Namespace to use if an ID needs to be generated for the to object - must be a unique prefix to the store
      Returns:
      Object URI for the copied object
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException - on SPDX parsing errors