1313import org .folio .anonymization .domain .job .SharedExecutionContext ;
1414import org .folio .anonymization .domain .job .TenantExecutionContext ;
1515import org .folio .anonymization .jobs .templates .RedactPart ;
16+ import org .folio .anonymization .repository .UtilRepository ;
1617import org .springframework .beans .factory .annotation .Autowired ;
1718import org .springframework .stereotype .Component ;
1819
@@ -33,17 +34,22 @@ public class TenantInfoRedaction implements JobFactory {
3334 @ Autowired
3435 private SharedExecutionContext context ;
3536
37+ @ Autowired
38+ private UtilRepository utilRepository ;
39+
3640 @ Override
3741 public List <JobBuilder > getBuilders (TenantExecutionContext tenant ) {
38- boolean tenantIsInTable = context
39- .create ()
40- .fetchExists (
41- context
42- .create ()
43- .selectOne ()
44- .from (TENANT_ID_FIELD .table ())
45- .where (TENANT_ID_FIELD .field (null , String .class ).eq (tenant .tenant ().id ()))
46- );
42+ boolean tenantInfoTableExists = utilRepository .doesTableExist (TENANT_ID_FIELD .schema (), TENANT_ID_FIELD .table ());
43+ boolean tenantIsInTable = tenantInfoTableExists &&
44+ context
45+ .create ()
46+ .fetchExists (
47+ context
48+ .create ()
49+ .selectOne ()
50+ .from (TENANT_ID_FIELD .table ())
51+ .where (TENANT_ID_FIELD .field (null , String .class ).eq (tenant .tenant ().id ()))
52+ );
4753
4854 return List .of (
4955 new JobBuilder (
@@ -57,7 +63,11 @@ public List<JobBuilder> getBuilders(TenantExecutionContext tenant) {
5763 if (!tenantIsInTable ) {
5864 return new JobConfigurationProperty (
5965 field ,
60- row (text (field .toString ()).crossedOut (), spacer (1 ), text ("(not present for tenant)" ).italic ()),
66+ row (
67+ text (field .toString ()).crossedOut (),
68+ spacer (1 ),
69+ text (tenantInfoTableExists ? "(not present for tenant)" : "(not available)" ).italic ()
70+ ),
6171 true ,
6272 true
6373 );
0 commit comments