21
21
import com .nuix .superutilities .misc .FormatUtility ;
22
22
23
23
import nuix .Item ;
24
+ import nuix .ItemCustomMetadataMap ;
24
25
25
26
/***
26
27
* Class for scanning a series of items with a series of regular expressions.
@@ -107,7 +108,7 @@ protected void fireScanError(RegexScanError error){
107
108
if (error .getLocation () != null ){
108
109
errorMessage .add ("\t Location: " +error .getLocation ());
109
110
}
110
- errorMessage .add ("\t Item GUID: " +error .getItem (). getGuid ());
111
+ errorMessage .add ("\t Item GUID: " +error .getItemGuid ());
111
112
logger .error (errorMessage .toString ());
112
113
logger .error (error .getException ());
113
114
}
@@ -444,12 +445,25 @@ protected ItemRegexMatchCollection scanItem(Item item) {
444
445
* @return Map of "stringified" metadata properties for the specified item
445
446
*/
446
447
public static Map <String ,String > getStringProperties (Item item , Set <String > specificProperties ){
448
+ // Note below String.intern use on property names which likely is highly repetitive
449
+
447
450
Map <String ,String > result = new HashMap <String ,String >();
448
- for (Entry <String , Object > entry : item .getProperties ().entrySet ()) {
449
- if (specificProperties == null || specificProperties .contains (entry .getKey ())){
450
- result .put (entry .getKey (), FormatUtility .getInstance ().convertToString (entry .getValue ()));
451
+
452
+ if (specificProperties == null | specificProperties .size () == 0 ) {
453
+ // We're scanning all the properties
454
+ for (Entry <String , Object > entry : item .getProperties ().entrySet ()) {
455
+ result .put (entry .getKey ().intern (), FormatUtility .getInstance ().convertToString (entry .getValue ()));
456
+ }
457
+ } else {
458
+ // We're just scanning specific properties
459
+ Map <String ,Object > itemProperties = item .getProperties ();
460
+ for (String specificProperty : specificProperties ) {
461
+ if (itemProperties .containsKey (specificProperty )) {
462
+ result .put (specificProperty .intern (), FormatUtility .getInstance ().convertToString (itemProperties .get (specificProperty )));
463
+ }
451
464
}
452
465
}
466
+
453
467
return result ;
454
468
}
455
469
@@ -462,11 +476,22 @@ public static Map<String,String> getStringProperties(Item item, Set<String> spec
462
476
*/
463
477
public static Map <String ,String > getStringCustomMetadata (Item item , Set <String > specificFields ){
464
478
Map <String ,String > result = new HashMap <String ,String >();
465
- for (Entry <String , Object > entry : item .getCustomMetadata ().entrySet ()) {
466
- if (specificFields == null || specificFields .contains (entry .getKey ())){
467
- result .put (entry .getKey (), FormatUtility .getInstance ().convertToString (entry .getValue ()));
479
+
480
+ if (specificFields == null || specificFields .size () == 0 ) {
481
+ // We're scanning all the custom metadata fields
482
+ for (Entry <String , Object > entry : item .getCustomMetadata ().entrySet ()) {
483
+ result .put (entry .getKey ().intern (), FormatUtility .getInstance ().convertToString (entry .getValue ()));
484
+ }
485
+ } else {
486
+ ItemCustomMetadataMap itemCustomMetadata = item .getCustomMetadata ();
487
+ // We're scanning specific custom metadata fields
488
+ for (String specificField : specificFields ) {
489
+ if (itemCustomMetadata .containsKey (specificField )) {
490
+ result .put (specificField .intern (),FormatUtility .getInstance ().convertToString (itemCustomMetadata .get (specificField )));
491
+ }
468
492
}
469
493
}
494
+
470
495
return result ;
471
496
}
472
497
0 commit comments