1111import org .jlab .clara .std .services .EventWriterException ;
1212import org .jlab .jnp .hipo4 .data .Bank ;
1313import org .jlab .jnp .hipo4 .data .Event ;
14+ import org .jlab .jnp .hipo4 .data .SchemaFactory ;
1415import org .jlab .jnp .hipo4 .io .HipoWriter ;
1516import org .jlab .jnp .hipo4 .io .HipoWriterSorted ;
1617import org .jlab .jnp .utils .file .FileUtils ;
@@ -25,6 +26,8 @@ public class HipoToHipoWriter extends AbstractEventWriterService<HipoWriterSorte
2526 private static final String CONF_COMPRESSION = "compression" ;
2627 private static final String CONF_SCHEMA_DIR = "schema_dir" ;
2728 private static final String CONF_SCHEMA_FILTER = "schema_filter" ;
29+ private static final String CONF_SCHEMA_WILDCARD = "wildcard" ;
30+
2831 private final List <Bank > schemaBankList = new ArrayList <Bank >();
2932 private final StringSubstitutor envSubstitutor = new StringSubstitutor (System .getenv ());
3033
@@ -56,9 +59,19 @@ private void configure(HipoWriterSorted writer, JSONObject opts) {
5659 schemaDir = envSubstitutor .replace (schemaDir );
5760 System .out .printf ("%s service: schema directory = %s%n" , getName (), schemaDir );
5861 }
59- writer .getSchemaFactory ().initFromDirectory (schemaDir );
6062
61- if (opts .has (CONF_SCHEMA_DIR )) {
63+ SchemaFactory factory = new SchemaFactory ();
64+ factory .initFromDirectory (schemaDir );
65+
66+ if (opts .has (CONF_SCHEMA_WILDCARD )==true ){
67+ String wildcard = opts .getString ("wildcard" );
68+ SchemaFactory f2 = factory .reduce (wildcard );
69+ writer .getSchemaFactory ().copy (f2 );
70+ } else {
71+ writer .getSchemaFactory ().copy (factory );
72+ }
73+
74+ if (opts .has (CONF_SCHEMA_DIR )==true ||opts .has (CONF_SCHEMA_WILDCARD )==true ) {
6275 boolean useFilter = opts .optBoolean (CONF_SCHEMA_FILTER , true );
6376 System .out .printf ("%s service: schema filter = %b%n" , getName (), useFilter );
6477 if (useFilter ==true ){
@@ -69,6 +82,10 @@ private void configure(HipoWriterSorted writer, JSONObject opts) {
6982 }
7083 }
7184 }
85+
86+ System .out .printf ("SERVICE WRITER :: [filter] %s\n " ,opts .has (HipoToHipoWriter .CONF_SCHEMA_FILTER ));
87+ System .out .printf ("SERVICE WRITER :: [dir] %s\n " ,opts .has (HipoToHipoWriter .CONF_SCHEMA_DIR ));
88+ System .out .printf ("SERVICE WRITER :: [wildcard] %s\n " ,opts .has (HipoToHipoWriter .CONF_SCHEMA_WILDCARD ));
7289 }
7390
7491 private Method getSchemaFilterSetter () throws NoSuchMethodException , SecurityException {
0 commit comments