Package org.spdx.library
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 Summary
Constructors Constructor Description ModelCopyManager()
Create a ModelCopyManager with default options
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canConvert(String fromSpecVersion, String toSpecVersion)
void
copy(org.spdx.storage.IModelStore toStore, String toObjectUri, org.spdx.storage.IModelStore fromStore, String fromObjectUri, String toSpecVersion, String toNamespace)
org.spdx.core.TypedValue
copy(org.spdx.storage.IModelStore toStore, org.spdx.storage.IModelStore fromStore, String sourceUri, String toSpecVersion, String toNamespace)
Copy an item from one Model Object Store to another using the source ID for the target unless it is anonymousString
getCopiedObjectUri(org.spdx.storage.IModelStore fromStore, String fromObjectUri, org.spdx.storage.IModelStore toStore)
ISpdxConverter
getSpecConverter(org.spdx.storage.IModelStore fromStore, org.spdx.storage.IModelStore toStore, String fromSpecVersion, String toSpecVersion, boolean create)
String
putCopiedId(org.spdx.storage.IModelStore fromStore, String fromObjectUri, org.spdx.storage.IModelStore toStore, String toObjectUri)
Record a copied ID between model storesboolean
versionsCompatible(String fromSpecVersion, String toSpecVersion)
-
-
-
Method Detail
-
versionsCompatible
public boolean versionsCompatible(String fromSpecVersion, String toSpecVersion)
- Parameters:
fromSpecVersion
- from spec versiontoSpecVersion
- 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 versiontoSpecVersion
- 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 interfaceorg.spdx.core.IModelCopyManager
- Parameters:
fromStore
- Store copied fromfromObjectUri
- Object URI in the from tsotretoStore
- 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 fromtoStore
- store converting tofromSpecVersion
- spec version converting fromtoSpecVersion
- spec version converting tocreate
- 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
-
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 interfaceorg.spdx.core.IModelCopyManager
- Parameters:
fromStore
- Store copied fromfromObjectUri
- URI for the from ObjecttoObjectUri
- 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 interfaceorg.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 interfaceorg.spdx.core.IModelCopyManager
- Parameters:
toStore
- Model Store to copy tofromStore
- Model Store containing the source itemsourceUri
- URI for the Source objecttoSpecVersion
- Version of the SPDX spec the to value complies withtoNamespace
- 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
-
-