@@ -123,7 +123,7 @@ public String putCopiedId(IModelStore fromStore, String fromDocumentUri, String
123123		}
124124		return  idMap .put (fromId , toId );
125125	}
126- 
126+ 	 
127127	/** 
128128	 * Copy an item from one Model Object Store to another 
129129	 * @param toStore Model Store to copy to 
@@ -136,6 +136,24 @@ public String putCopiedId(IModelStore fromStore, String fromDocumentUri, String
136136	 * @throws InvalidSPDXAnalysisException 
137137	 */ 
138138	public  void  copy (IModelStore  toStore , String  toDocumentUri , String  toId , IModelStore  fromStore , String  fromDocumentUri , String  fromId , String  type ) throws  InvalidSPDXAnalysisException  {
139+ 		copy (toStore , toDocumentUri , toId , fromStore , fromDocumentUri , fromId , type , false );
140+ 	}
141+ 
142+ 	/** 
143+ 	 * Copy an item from one Model Object Store to another 
144+ 	 * @param toStore Model Store to copy to 
145+ 	 * @param toId Id to use in the copy 
146+ 	 * @param toDocumentUri Target document URI 
147+ 	 * @param fromStore Model Store containing the source item 
148+ 	 * @param fromDocumentUri Document URI for the source item 
149+ 	 * @param fromId ID source ID 
150+ 	 * @param type Type to copy 
151+ 	 * @param excludeLicenseDetails If true, don't copy over properties of the listed licenses 
152+ 	 * @throws InvalidSPDXAnalysisException 
153+ 	 */ 
154+ 	public  void  copy (IModelStore  toStore , String  toDocumentUri , String  toId , 
155+ 			IModelStore  fromStore , String  fromDocumentUri , String  fromId , 
156+ 			String  type , boolean  excludeLicenseDetails ) throws  InvalidSPDXAnalysisException  {
139157		Objects .requireNonNull (toStore , "ToStore can not be null" );
140158		Objects .requireNonNull (toDocumentUri , "To Document URI can not be null" );
141159		Objects .requireNonNull (fromStore , "FromStore can not be null" );
@@ -150,12 +168,16 @@ public void copy(IModelStore toStore, String toDocumentUri, String toId, IModelS
150168			toStore .create (toDocumentUri , toId , type );
151169		}
152170		putCopiedId (fromStore , fromDocumentUri , fromId , toStore , toDocumentUri , toId );
153- 		List <String > propertyNames  = fromStore .getPropertyValueNames (fromDocumentUri , fromId );
154- 		for  (String  propName :propertyNames ) {
155- 			if  (fromStore .isCollectionProperty (fromDocumentUri , fromId , propName )) {
156- 			    copyCollectionProperty (toStore , toDocumentUri , toId , fromStore , fromDocumentUri , fromId , propName );
157- 			} else  {
158- 			    copyIndividualProperty (toStore , toDocumentUri , toId , fromStore , fromDocumentUri , fromId , propName );
171+ 		if  (!(excludeLicenseDetails  && 
172+ 				(SpdxConstants .CLASS_SPDX_LISTED_LICENSE .equals (type ) ||
173+ 						SpdxConstants .CLASS_SPDX_LISTED_LICENSE_EXCEPTION .equals (type )))) {
174+ 			List <String > propertyNames  = fromStore .getPropertyValueNames (fromDocumentUri , fromId );
175+ 			for  (String  propName :propertyNames ) {
176+ 				if  (fromStore .isCollectionProperty (fromDocumentUri , fromId , propName )) {
177+ 				    copyCollectionProperty (toStore , toDocumentUri , toId , fromStore , fromDocumentUri , fromId , propName , excludeLicenseDetails );
178+ 				} else  {
179+ 				    copyIndividualProperty (toStore , toDocumentUri , toId , fromStore , fromDocumentUri , fromId , propName , excludeLicenseDetails );
180+ 				}
159181			}
160182		}
161183	}
@@ -169,10 +191,11 @@ public void copy(IModelStore toStore, String toDocumentUri, String toId, IModelS
169191     * @param fromDocumentUri Document URI for the source item 
170192     * @param fromId ID source ID 
171193     * @param propName Name of the property 
194+      * @param excludeLicenseDetails If true, don't copy over properties of the listed licenses 
172195	 * @throws InvalidSPDXAnalysisException 
173196	 */ 
174197	private  void  copyIndividualProperty (IModelStore  toStore , String  toDocumentUri , String  toId , IModelStore  fromStore ,
175-             String  fromDocumentUri , String  fromId , String  propName ) throws  InvalidSPDXAnalysisException  {
198+             String  fromDocumentUri , String  fromId , String  propName ,  boolean   excludeLicenseDetails ) throws  InvalidSPDXAnalysisException  {
176199       if  (fromStore .isCollectionProperty (fromDocumentUri , fromId , propName )) {
177200            throw  new  InvalidSPDXAnalysisException ("Property " +propName +" is a collection type" );
178201        }
@@ -187,7 +210,7 @@ private void copyIndividualProperty(IModelStore toStore, String toDocumentUri, S
187210                } else  {
188211                    toStore .setValue (toDocumentUri , toId , propName , 
189212                            copy (toStore , toDocumentUri , fromStore , fromDocumentUri , 
190-                                     tv .getId (), tv .getType ()));
213+                                     tv .getId (), tv .getType (),  excludeLicenseDetails ));
191214                }
192215            } else  {
193216                toStore .setValue (toDocumentUri , toId , propName , result .get ());
@@ -204,10 +227,11 @@ private void copyIndividualProperty(IModelStore toStore, String toDocumentUri, S
204227     * @param fromDocumentUri Document URI for the source item 
205228     * @param fromId ID source ID 
206229	 * @param propName Name of the property 
230+ 	 * @param excludeLicenseDetails If true, don't copy over properties of the listed licenses 
207231	 * @throws InvalidSPDXAnalysisException 
208232	 */ 
209233	private  void  copyCollectionProperty (IModelStore  toStore , String  toDocumentUri , String  toId , IModelStore  fromStore ,
210-             String  fromDocumentUri , String  fromId , String  propName ) throws  InvalidSPDXAnalysisException  {
234+             String  fromDocumentUri , String  fromId , String  propName ,  boolean   excludeLicenseDetails ) throws  InvalidSPDXAnalysisException  {
211235	    if  (!fromStore .isCollectionProperty (fromDocumentUri , fromId , propName )) {
212236	        throw  new  InvalidSPDXAnalysisException ("Property " +propName +" is not a collection type" );
213237	    }
@@ -223,14 +247,30 @@ private void copyCollectionProperty(IModelStore toStore, String toDocumentUri, S
223247                    toStoreItem  = listItemTv ;
224248                } else  {
225249                    toStoreItem  = copy (toStore , toDocumentUri , fromStore , fromDocumentUri , 
226-                                     listItemTv .getId (), listItemTv .getType ());
250+                                     listItemTv .getId (), listItemTv .getType (),  excludeLicenseDetails );
227251                }
228252            } else  {
229253                toStoreItem  = listItem ;
230254            }
231255            toStore .addValueToCollection (toDocumentUri , toId , propName , toStoreItem );
232256        }
233257    }
258+ 	
259+ 	/** 
260+ 	 * Copy an item from one Model Object Store to another using the source ID for the target unless it is anonymous 
261+ 	 * @param toStore Model Store to copy to 
262+ 	 * @param toDocumentUri Target document URI 
263+ 	 * @param fromStore Model Store containing the source item 
264+ 	 * @param fromDocumentUri Document URI for the source item 
265+ 	 * @param sourceId ID source ID 
266+ 	 * @param type Type to copy 
267+ 	 * @return ID for the copied object 
268+ 	 * @throws InvalidSPDXAnalysisException 
269+ 	 */ 
270+ 	public  TypedValue  copy (IModelStore  toStore , String  toDocumentUri , IModelStore  fromStore , 
271+ 			String  fromDocumentUri , String  sourceId , String  type ) throws  InvalidSPDXAnalysisException  {
272+ 		return  copy (toStore , toDocumentUri , fromStore , fromDocumentUri , sourceId , type , false );
273+ 	}
234274
235275    /** 
236276	 * Copy an item from one Model Object Store to another using the source ID for the target unless it is anonymous 
@@ -240,11 +280,12 @@ private void copyCollectionProperty(IModelStore toStore, String toDocumentUri, S
240280	 * @param fromDocumentUri Document URI for the source item 
241281	 * @param sourceId ID source ID 
242282	 * @param type Type to copy 
283+ 	 * @param excludeLicenseDetails If true, don't copy over properties of the listed licenses 
243284	 * @return ID for the copied object 
244285	 * @throws InvalidSPDXAnalysisException 
245286	 */ 
246287	public  TypedValue  copy (IModelStore  toStore , String  toDocumentUri , IModelStore  fromStore , 
247- 			String  fromDocumentUri , String  sourceId , String  type ) throws  InvalidSPDXAnalysisException  {
288+ 			String  fromDocumentUri , String  sourceId , String  type ,  boolean   excludeLicenseDetails ) throws  InvalidSPDXAnalysisException  {
248289		Objects .requireNonNull (toStore , "To Store can not be null" );
249290		Objects .requireNonNull (toDocumentUri , "To Document URI can not be null" );
250291		Objects .requireNonNull (fromStore , "From Store can not be null" );
@@ -271,7 +312,7 @@ public TypedValue copy(IModelStore toStore, String toDocumentUri, IModelStore fr
271312			} else  {
272313				toId  = sourceId ;
273314			}
274- 			copy (toStore , toDocumentUri , toId , fromStore , fromDocumentUri , sourceId , type );
315+ 			copy (toStore , toDocumentUri , toId , fromStore , fromDocumentUri , sourceId , type ,  excludeLicenseDetails );
275316		}
276317		return  new  TypedValue (toId , type );
277318	}
0 commit comments