Skip to content

Commit

Permalink
hide generator internals
Browse files Browse the repository at this point in the history
  • Loading branch information
banderous committed Mar 5, 2021
1 parent fe22f3e commit ba9af19
Show file tree
Hide file tree
Showing 86 changed files with 197 additions and 228 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.hmcts.ccd.sdk.generator;
package uk.gov.hmcts.ccd.sdk;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
Expand All @@ -11,7 +11,7 @@
import uk.gov.hmcts.ccd.sdk.JsonUtils;
import uk.gov.hmcts.ccd.sdk.JsonUtils.AddMissing;

public class AuthorisationCaseEventGenerator {
class AuthorisationCaseEventGenerator {

public static void generate(File root,
Table<String, String, String> eventRolePermissions,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.hmcts.ccd.sdk.generator;
package uk.gov.hmcts.ccd.sdk;

import com.google.common.base.Strings;
import com.google.common.collect.HashBasedTable;
Expand All @@ -19,23 +19,22 @@
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
import uk.gov.hmcts.ccd.sdk.JsonUtils;
import uk.gov.hmcts.ccd.sdk.JsonUtils.CRUDMerger;
import uk.gov.hmcts.ccd.sdk.types.Event;
import uk.gov.hmcts.ccd.sdk.types.Field;
import uk.gov.hmcts.ccd.sdk.types.Field.FieldBuilder;
import uk.gov.hmcts.ccd.sdk.types.HasRole;
import uk.gov.hmcts.ccd.sdk.types.Search;
import uk.gov.hmcts.ccd.sdk.types.Search.SearchBuilder;
import uk.gov.hmcts.ccd.sdk.types.SearchField;
import uk.gov.hmcts.ccd.sdk.types.Tab;
import uk.gov.hmcts.ccd.sdk.types.Tab.TabBuilder;
import uk.gov.hmcts.ccd.sdk.types.TabField;
import uk.gov.hmcts.ccd.sdk.types.WorkBasket;
import uk.gov.hmcts.ccd.sdk.types.WorkBasket.WorkBasketBuilder;
import uk.gov.hmcts.ccd.sdk.types.WorkBasketField;

public class AuthorisationCaseFieldGenerator {
import uk.gov.hmcts.ccd.sdk.api.Event;
import uk.gov.hmcts.ccd.sdk.api.Field;
import uk.gov.hmcts.ccd.sdk.api.Field.FieldBuilder;
import uk.gov.hmcts.ccd.sdk.api.HasRole;
import uk.gov.hmcts.ccd.sdk.api.Search;
import uk.gov.hmcts.ccd.sdk.api.Search.SearchBuilder;
import uk.gov.hmcts.ccd.sdk.api.SearchField;
import uk.gov.hmcts.ccd.sdk.api.Tab;
import uk.gov.hmcts.ccd.sdk.api.Tab.TabBuilder;
import uk.gov.hmcts.ccd.sdk.api.TabField;
import uk.gov.hmcts.ccd.sdk.api.WorkBasket;
import uk.gov.hmcts.ccd.sdk.api.WorkBasket.WorkBasketBuilder;
import uk.gov.hmcts.ccd.sdk.api.WorkBasketField;

class AuthorisationCaseFieldGenerator {

public static void generate(File root, String caseType, List<Event> events,
Table<String, String, String> eventRolePermissions, List<TabBuilder> tabs,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.hmcts.ccd.sdk.generator;
package uk.gov.hmcts.ccd.sdk;

import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Lists;
Expand All @@ -16,11 +16,10 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import uk.gov.hmcts.ccd.sdk.JsonUtils;
import uk.gov.hmcts.ccd.sdk.JsonUtils.CRUDMerger;
import uk.gov.hmcts.ccd.sdk.types.Event;
import uk.gov.hmcts.ccd.sdk.api.Event;

public class AuthorisationCaseStateGenerator {
class AuthorisationCaseStateGenerator {

public static void generate(File root, String caseType, List<Event> events,
Table<String, String, String> eventRolePermissions) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package uk.gov.hmcts.ccd.sdk.generator;
package uk.gov.hmcts.ccd.sdk;

import com.google.common.collect.Lists;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import uk.gov.hmcts.ccd.sdk.JsonUtils;
import uk.gov.hmcts.ccd.sdk.types.HasRole;
import uk.gov.hmcts.ccd.sdk.api.HasRole;

public class AuthorisationCaseTypeGenerator {
class AuthorisationCaseTypeGenerator {
public static void generate(File root, String caseType, Class roleEnum) {

List<Map<String, Object>> result = Lists.newArrayList();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.hmcts.ccd.sdk.generator;
package uk.gov.hmcts.ccd.sdk;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableListMultimap;
Expand All @@ -11,12 +11,11 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import uk.gov.hmcts.ccd.sdk.JsonUtils;
import uk.gov.hmcts.ccd.sdk.JsonUtils.AddMissing;
import uk.gov.hmcts.ccd.sdk.types.Event;
import uk.gov.hmcts.ccd.sdk.types.Webhook;
import uk.gov.hmcts.ccd.sdk.api.Event;
import uk.gov.hmcts.ccd.sdk.api.Webhook;

public class CaseEventGenerator {
class CaseEventGenerator {

public static void writeEvents(File root, String caseType, List<Event> events) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.hmcts.ccd.sdk.generator;
package uk.gov.hmcts.ccd.sdk;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableListMultimap;
Expand All @@ -10,13 +10,12 @@
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import uk.gov.hmcts.ccd.sdk.JsonUtils;
import uk.gov.hmcts.ccd.sdk.JsonUtils.AddMissing;
import uk.gov.hmcts.ccd.sdk.types.Event;
import uk.gov.hmcts.ccd.sdk.types.Field;
import uk.gov.hmcts.ccd.sdk.types.FieldCollection;
import uk.gov.hmcts.ccd.sdk.api.Event;
import uk.gov.hmcts.ccd.sdk.api.Field;
import uk.gov.hmcts.ccd.sdk.api.FieldCollection;

public class CaseEventToComplexTypesGenerator {
class CaseEventToComplexTypesGenerator {

public static void writeEvents(File root, List<Event> events) {
for (Event event : events) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.hmcts.ccd.sdk.generator;
package uk.gov.hmcts.ccd.sdk;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
Expand All @@ -8,13 +8,12 @@
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import uk.gov.hmcts.ccd.sdk.JsonUtils;
import uk.gov.hmcts.ccd.sdk.JsonUtils.AddMissing;
import uk.gov.hmcts.ccd.sdk.types.Event;
import uk.gov.hmcts.ccd.sdk.types.Field;
import uk.gov.hmcts.ccd.sdk.types.FieldCollection;
import uk.gov.hmcts.ccd.sdk.api.Event;
import uk.gov.hmcts.ccd.sdk.api.Field;
import uk.gov.hmcts.ccd.sdk.api.FieldCollection;

public class CaseEventToFieldsGenerator {
class CaseEventToFieldsGenerator {

public static void writeEvents(File root, List<Event> events, String caseType) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.hmcts.ccd.sdk.generator;
package uk.gov.hmcts.ccd.sdk;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand All @@ -18,17 +18,15 @@
import java.util.Set;
import net.jodah.typetools.TypeResolver;
import org.reflections.ReflectionUtils;
import uk.gov.hmcts.ccd.sdk.ConfigBuilderImpl;
import uk.gov.hmcts.ccd.sdk.JsonUtils;
import uk.gov.hmcts.ccd.sdk.JsonUtils.OverwriteSpecific;
import uk.gov.hmcts.ccd.sdk.types.CCD;
import uk.gov.hmcts.ccd.sdk.types.ComplexType;
import uk.gov.hmcts.ccd.sdk.types.Event;
import uk.gov.hmcts.ccd.sdk.types.Field.FieldBuilder;
import uk.gov.hmcts.ccd.sdk.types.FieldType;
import uk.gov.hmcts.ccd.sdk.types.Label;
import uk.gov.hmcts.ccd.sdk.api.CCD;
import uk.gov.hmcts.ccd.sdk.api.ComplexType;
import uk.gov.hmcts.ccd.sdk.api.Event;
import uk.gov.hmcts.ccd.sdk.api.Field.FieldBuilder;
import uk.gov.hmcts.ccd.sdk.api.FieldType;
import uk.gov.hmcts.ccd.sdk.api.Label;

public class CaseFieldGenerator {
class CaseFieldGenerator {

// The field type set from code always takes precedence,
// so eg. if a field changes type it gets updated.
Expand Down Expand Up @@ -180,26 +178,26 @@ private static void inferFieldType(Class dataClass, Field field, Map<String, Obj

private static List<Map<String, Object>> getExplicitFields(String caseType, List<Event> events,
ConfigBuilderImpl builder) {
Map<String, uk.gov.hmcts.ccd.sdk.types.Field> explicitFields = Maps.newHashMap();
Map<String, uk.gov.hmcts.ccd.sdk.api.Field> explicitFields = Maps.newHashMap();
for (Event event : events) {
List<uk.gov.hmcts.ccd.sdk.types.Field.FieldBuilder> fc = event.getFields().build()
List<uk.gov.hmcts.ccd.sdk.api.Field.FieldBuilder> fc = event.getFields().build()
.getExplicitFields();

for (uk.gov.hmcts.ccd.sdk.types.Field.FieldBuilder fieldBuilder : fc) {
uk.gov.hmcts.ccd.sdk.types.Field field = fieldBuilder.build();
for (uk.gov.hmcts.ccd.sdk.api.Field.FieldBuilder fieldBuilder : fc) {
uk.gov.hmcts.ccd.sdk.api.Field field = fieldBuilder.build();
explicitFields.put(field.getId(), field);
}
}

List<uk.gov.hmcts.ccd.sdk.types.Field.FieldBuilder> fs = builder.explicitFields;
List<uk.gov.hmcts.ccd.sdk.api.Field.FieldBuilder> fs = builder.explicitFields;
for (FieldBuilder explicitField : fs) {
uk.gov.hmcts.ccd.sdk.types.Field field = explicitField.build();
uk.gov.hmcts.ccd.sdk.api.Field field = explicitField.build();
explicitFields.put(field.getId(), field);
}

List<Map<String, Object>> result = Lists.newArrayList();
for (String fieldId : explicitFields.keySet()) {
uk.gov.hmcts.ccd.sdk.types.Field field = explicitFields.get(fieldId);
uk.gov.hmcts.ccd.sdk.api.Field field = explicitFields.get(fieldId);
Map<String, Object> fieldData = getField(caseType, fieldId);
// Don't export inbuilt metadata fields.
if (fieldId.matches("\\[.+\\]")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.hmcts.ccd.sdk.generator;
package uk.gov.hmcts.ccd.sdk;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
Expand All @@ -7,15 +7,13 @@
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import uk.gov.hmcts.ccd.sdk.ConfigBuilderImpl;
import uk.gov.hmcts.ccd.sdk.JsonUtils;
import uk.gov.hmcts.ccd.sdk.JsonUtils.AddMissing;
import uk.gov.hmcts.ccd.sdk.types.HasRole;
import uk.gov.hmcts.ccd.sdk.types.Tab;
import uk.gov.hmcts.ccd.sdk.types.Tab.TabBuilder;
import uk.gov.hmcts.ccd.sdk.types.TabField;
import uk.gov.hmcts.ccd.sdk.api.HasRole;
import uk.gov.hmcts.ccd.sdk.api.Tab;
import uk.gov.hmcts.ccd.sdk.api.Tab.TabBuilder;
import uk.gov.hmcts.ccd.sdk.api.TabField;

public class CaseTypeTabGenerator {
class CaseTypeTabGenerator {

public static <T, R extends HasRole, S> void generate(File root, String caseType,
ConfigBuilderImpl<T, S, R> builder) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package uk.gov.hmcts.ccd.sdk.generator;
package uk.gov.hmcts.ccd.sdk;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import uk.gov.hmcts.ccd.sdk.JsonUtils;
import uk.gov.hmcts.ccd.sdk.JsonUtils.AddMissing;
import uk.gov.hmcts.ccd.sdk.types.ComplexType;
import uk.gov.hmcts.ccd.sdk.api.ComplexType;

public class ComplexTypeGenerator {
class ComplexTypeGenerator {

public static void generate(File root, String caseType, Map<Class, Integer> types) {
File complexTypes = new File(root, "ComplexTypes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import uk.gov.hmcts.ccd.sdk.types.ConfigBuilder;
import uk.gov.hmcts.ccd.sdk.types.Event;
import uk.gov.hmcts.ccd.sdk.types.EventTypeBuilder;
import uk.gov.hmcts.ccd.sdk.types.Field;
import uk.gov.hmcts.ccd.sdk.types.Field.FieldBuilder;
import uk.gov.hmcts.ccd.sdk.types.HasRole;
import uk.gov.hmcts.ccd.sdk.types.RoleBuilder;
import uk.gov.hmcts.ccd.sdk.types.Search.SearchBuilder;
import uk.gov.hmcts.ccd.sdk.types.Tab;
import uk.gov.hmcts.ccd.sdk.types.Tab.TabBuilder;
import uk.gov.hmcts.ccd.sdk.types.Webhook;
import uk.gov.hmcts.ccd.sdk.types.WebhookConvention;
import uk.gov.hmcts.ccd.sdk.types.WorkBasket.WorkBasketBuilder;

public class ConfigBuilderImpl<T, S, R extends HasRole> implements ConfigBuilder<T, S, R> {
import uk.gov.hmcts.ccd.sdk.api.ConfigBuilder;
import uk.gov.hmcts.ccd.sdk.api.Event;
import uk.gov.hmcts.ccd.sdk.api.EventTypeBuilder;
import uk.gov.hmcts.ccd.sdk.api.Field;
import uk.gov.hmcts.ccd.sdk.api.Field.FieldBuilder;
import uk.gov.hmcts.ccd.sdk.api.HasRole;
import uk.gov.hmcts.ccd.sdk.api.RoleBuilder;
import uk.gov.hmcts.ccd.sdk.api.Search.SearchBuilder;
import uk.gov.hmcts.ccd.sdk.api.Tab;
import uk.gov.hmcts.ccd.sdk.api.Tab.TabBuilder;
import uk.gov.hmcts.ccd.sdk.api.Webhook;
import uk.gov.hmcts.ccd.sdk.api.WebhookConvention;
import uk.gov.hmcts.ccd.sdk.api.WorkBasket.WorkBasketBuilder;

class ConfigBuilderImpl<T, S, R extends HasRole> implements ConfigBuilder<T, S, R> {

public String caseType = "";
public final Multimap<String, String> stateRoleHistoryAccess = ArrayListMultimap.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,10 @@
import org.objenesis.ObjenesisStd;
import org.reflections.ReflectionUtils;
import org.reflections.Reflections;
import uk.gov.hmcts.ccd.sdk.generator.AuthorisationCaseEventGenerator;
import uk.gov.hmcts.ccd.sdk.generator.AuthorisationCaseFieldGenerator;
import uk.gov.hmcts.ccd.sdk.generator.AuthorisationCaseStateGenerator;
import uk.gov.hmcts.ccd.sdk.generator.AuthorisationCaseTypeGenerator;
import uk.gov.hmcts.ccd.sdk.generator.CaseEventGenerator;
import uk.gov.hmcts.ccd.sdk.generator.CaseEventToComplexTypesGenerator;
import uk.gov.hmcts.ccd.sdk.generator.CaseEventToFieldsGenerator;
import uk.gov.hmcts.ccd.sdk.generator.CaseFieldGenerator;
import uk.gov.hmcts.ccd.sdk.generator.CaseTypeTabGenerator;
import uk.gov.hmcts.ccd.sdk.generator.ComplexTypeGenerator;
import uk.gov.hmcts.ccd.sdk.generator.FixedListGenerator;
import uk.gov.hmcts.ccd.sdk.generator.SearchFieldAndResultGenerator;
import uk.gov.hmcts.ccd.sdk.generator.StateGenerator;
import uk.gov.hmcts.ccd.sdk.generator.WorkBasketGenerator;
import uk.gov.hmcts.ccd.sdk.types.CCDConfig;
import uk.gov.hmcts.ccd.sdk.types.Event;

public class ConfigGenerator {
import uk.gov.hmcts.ccd.sdk.api.CCDConfig;
import uk.gov.hmcts.ccd.sdk.api.Event;

class ConfigGenerator {

private final Reflections reflections;
private final String basePackage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.hmcts.ccd.sdk.generator;
package uk.gov.hmcts.ccd.sdk;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
Expand All @@ -7,11 +7,10 @@
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import uk.gov.hmcts.ccd.sdk.JsonUtils;
import uk.gov.hmcts.ccd.sdk.JsonUtils.AddMissing;
import uk.gov.hmcts.ccd.sdk.types.HasLabel;
import uk.gov.hmcts.ccd.sdk.api.HasLabel;

public class FixedListGenerator {
class FixedListGenerator {

public static void generate(File root, Map<Class, Integer> types) {
File dir = root.toPath().resolve("FixedLists").toFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;

public class JsonUtils {
class JsonUtils {

@SneakyThrows
private static void writeFile(Path path, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;

public class Main {
class Main {

public static void main(String[] args) {
File outputDir = new File(args[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.beans.PropertyDescriptor;
import java.lang.annotation.Annotation;

public class PropertyUtils implements uk.gov.hmcts.ccd.sdk.types.PropertyUtils {
class PropertyUtils implements uk.gov.hmcts.ccd.sdk.api.PropertyUtils {

@Override
public <T, A extends Annotation> A getAnnotationOfProperty(Class<T> entityType,
Expand Down
Loading

0 comments on commit ba9af19

Please sign in to comment.