refactor: add lombok to hooks module
This commit is contained in:
committed by
Arnold Gálovics
parent
5d1d20e577
commit
5b935eb1ff
+6
@@ -21,11 +21,17 @@ package org.apache.fineract.infrastructure.hooks.data;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class Entity implements Serializable {
|
public class Entity implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private List<String> actions;
|
private List<String> actions;
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-8
@@ -19,18 +19,21 @@
|
|||||||
package org.apache.fineract.infrastructure.hooks.data;
|
package org.apache.fineract.infrastructure.hooks.data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import lombok.AccessLevel;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
@Data
|
||||||
@Getter
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public final class Event implements Serializable {
|
public final class Event implements Serializable {
|
||||||
|
|
||||||
private final String actionName;
|
private static final long serialVersionUID = 1L;
|
||||||
private final String entityName;
|
|
||||||
|
private String actionName;
|
||||||
|
private String entityName;
|
||||||
|
|
||||||
public static Event instance(final String actionName, final String entityName) {
|
public static Event instance(final String actionName, final String entityName) {
|
||||||
return new Event(actionName, entityName);
|
return new Event().setActionName(actionName).setEntityName(entityName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-12
@@ -19,26 +19,29 @@
|
|||||||
package org.apache.fineract.infrastructure.hooks.data;
|
package org.apache.fineract.infrastructure.hooks.data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import lombok.AccessLevel;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
@Data
|
||||||
@Getter
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public final class Field implements Serializable {
|
public final class Field implements Serializable {
|
||||||
|
|
||||||
private final String fieldName;
|
private static final long serialVersionUID = 1L;
|
||||||
private final String fieldValue;
|
|
||||||
private final String fieldType;
|
private String fieldName;
|
||||||
private final Boolean optional;
|
private String fieldValue;
|
||||||
private final String placeholder;
|
private String fieldType;
|
||||||
|
private Boolean optional;
|
||||||
|
private String placeholder;
|
||||||
|
|
||||||
public static Field fromConfig(final String fieldName, final String fieldValue) {
|
public static Field fromConfig(final String fieldName, final String fieldValue) {
|
||||||
return new Field(fieldName, fieldValue, null, null, null);
|
return new Field().setFieldName(fieldName).setFieldValue(fieldValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Field fromSchema(final String fieldType, final String fieldName, final Boolean optional, final String placeholder) {
|
public static Field fromSchema(final String fieldType, final String fieldName, final Boolean optional, final String placeholder) {
|
||||||
return new Field(fieldName, null, fieldType, optional, placeholder);
|
return new Field().setFieldName(fieldName).setFieldType(fieldType).setOptional(optional).setPlaceholder(placeholder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -21,11 +21,17 @@ package org.apache.fineract.infrastructure.hooks.data;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class Grouping implements Serializable {
|
public class Grouping implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private List<Entity> entities;
|
private List<Entity> entities;
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-22
@@ -21,45 +21,50 @@ package org.apache.fineract.infrastructure.hooks.data;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.AccessLevel;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
@Data
|
||||||
@Getter
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public final class HookData implements Serializable {
|
public final class HookData implements Serializable {
|
||||||
|
|
||||||
private final Long id;
|
private static final long serialVersionUID = 1L;
|
||||||
private final String name;
|
private Long id;
|
||||||
private final String displayName;
|
private String name;
|
||||||
private final Boolean isActive;
|
private String displayName;
|
||||||
private final LocalDate createdAt;
|
private Boolean isActive;
|
||||||
private final LocalDate updatedAt;
|
private LocalDate createdAt;
|
||||||
private final Long templateId;
|
private LocalDate updatedAt;
|
||||||
private final String templateName;
|
private Long templateId;
|
||||||
|
private String templateName;
|
||||||
|
|
||||||
// associations
|
// associations
|
||||||
private final List<Event> events;
|
private List<Event> events;
|
||||||
private final List<Field> config;
|
private List<Field> config;
|
||||||
|
|
||||||
// template data
|
// template data
|
||||||
private final List<HookTemplateData> templates;
|
private List<HookTemplateData> templates;
|
||||||
private final List<Grouping> groupings;
|
private List<Grouping> groupings;
|
||||||
|
|
||||||
public static HookData instance(final Long id, final String name, final String displayName, final boolean isActive,
|
public static HookData instance(final Long id, final String name, final String displayName, final boolean isActive,
|
||||||
final LocalDate createdAt, final LocalDate updatedAt, final Long templateId, final List<Event> registeredEvents,
|
final LocalDate createdAt, final LocalDate updatedAt, final Long templateId, final List<Event> registeredEvents,
|
||||||
final List<Field> config, final String templateName) {
|
final List<Field> config, final String templateName) {
|
||||||
return new HookData(id, name, displayName, isActive, createdAt, updatedAt, templateId, templateName, registeredEvents, config, null,
|
return new HookData().setId(id).setName(name).setDisplayName(displayName).setIsActive(isActive).setCreatedAt(createdAt)
|
||||||
null);
|
.setUpdatedAt(updatedAt).setTemplateId(templateId).setTemplateName(templateName).setEvents(registeredEvents)
|
||||||
|
.setConfig(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HookData template(final List<HookTemplateData> templates, final List<Grouping> groupings) {
|
public static HookData template(final List<HookTemplateData> templates, final List<Grouping> groupings) {
|
||||||
return new HookData(null, null, null, null, null, null, null, null, null, null, templates, groupings);
|
return new HookData().setTemplates(templates).setGroupings(groupings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HookData templateExisting(final HookData hookData, final List<HookTemplateData> templates,
|
public static HookData templateExisting(final HookData hookData, final List<HookTemplateData> templates,
|
||||||
final List<Grouping> groupings) {
|
final List<Grouping> groupings) {
|
||||||
return new HookData(hookData.id, hookData.name, hookData.displayName, hookData.isActive, hookData.createdAt, hookData.updatedAt,
|
return new HookData().setId(hookData.id).setName(hookData.name).setDisplayName(hookData.displayName).setIsActive(hookData.isActive)
|
||||||
hookData.templateId, hookData.templateName, hookData.events, hookData.config, templates, groupings);
|
.setCreatedAt(hookData.createdAt).setUpdatedAt(hookData.updatedAt).setTemplateId(hookData.templateId)
|
||||||
|
.setTemplateName(hookData.templateName).setEvents(hookData.events).setConfig(hookData.config).setTemplates(templates)
|
||||||
|
.setGroupings(groupings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-11
@@ -20,25 +20,26 @@ package org.apache.fineract.infrastructure.hooks.data;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.AccessLevel;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public final class HookTemplateData implements Serializable {
|
public final class HookTemplateData implements Serializable {
|
||||||
|
|
||||||
private final Long id;
|
private static final long serialVersionUID = 1L;
|
||||||
private final String name;
|
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
// associations
|
// associations
|
||||||
private final List<Field> schema;
|
private List<Field> schema;
|
||||||
|
|
||||||
public static HookTemplateData instance(final Long id, final String name, final List<Field> schema) {
|
public static HookTemplateData instance(final Long id, final String name, final List<Field> schema) {
|
||||||
return new HookTemplateData(id, name, schema);
|
return new HookTemplateData().setId(id).setName(name).setSchema(schema);
|
||||||
}
|
|
||||||
|
|
||||||
public Long getServiceId() {
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-21
@@ -38,6 +38,10 @@ import javax.persistence.JoinColumn;
|
|||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||||
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
|
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
|
||||||
@@ -46,7 +50,11 @@ import org.springframework.util.CollectionUtils;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "m_hook")
|
@Table(name = "m_hook")
|
||||||
public class Hook extends AbstractAuditableCustom {
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public final class Hook extends AbstractAuditableCustom {
|
||||||
|
|
||||||
@Column(name = "name", nullable = false, length = 100)
|
@Column(name = "name", nullable = false, length = 100)
|
||||||
private String name;
|
private String name;
|
||||||
@@ -68,8 +76,6 @@ public class Hook extends AbstractAuditableCustom {
|
|||||||
@JoinColumn(name = "ugd_template_id", referencedColumnName = "id", nullable = true)
|
@JoinColumn(name = "ugd_template_id", referencedColumnName = "id", nullable = true)
|
||||||
private Template ugdTemplate;
|
private Template ugdTemplate;
|
||||||
|
|
||||||
protected Hook() {}
|
|
||||||
|
|
||||||
public static Hook fromJson(final JsonCommand command, final HookTemplate template, final Set<HookConfiguration> config,
|
public static Hook fromJson(final JsonCommand command, final HookTemplate template, final Set<HookConfiguration> config,
|
||||||
final Set<HookResource> events, final Template ugdTemplate) {
|
final Set<HookResource> events, final Template ugdTemplate) {
|
||||||
final String displayName = command.stringValueOfParameterNamed(displayNameParamName);
|
final String displayName = command.stringValueOfParameterNamed(displayNameParamName);
|
||||||
@@ -103,26 +109,18 @@ public class Hook extends AbstractAuditableCustom {
|
|||||||
|
|
||||||
private Set<HookConfiguration> associateConfigWithThisHook(final Set<HookConfiguration> config) {
|
private Set<HookConfiguration> associateConfigWithThisHook(final Set<HookConfiguration> config) {
|
||||||
for (final HookConfiguration hookConfiguration : config) {
|
for (final HookConfiguration hookConfiguration : config) {
|
||||||
hookConfiguration.update(this);
|
hookConfiguration.setHook(this);
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<HookResource> associateEventsWithThisHook(final Set<HookResource> events) {
|
private Set<HookResource> associateEventsWithThisHook(final Set<HookResource> events) {
|
||||||
for (final HookResource hookResource : events) {
|
for (final HookResource hookResource : events) {
|
||||||
hookResource.update(this);
|
hookResource.setHook(this);
|
||||||
}
|
}
|
||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HookTemplate getHookTemplate() {
|
|
||||||
return this.template;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Template getUgdTemplate() {
|
|
||||||
return this.ugdTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getUgdTemplateId() {
|
public Long getUgdTemplateId() {
|
||||||
Long templateId = null;
|
Long templateId = null;
|
||||||
if (this.ugdTemplate != null) {
|
if (this.ugdTemplate != null) {
|
||||||
@@ -131,10 +129,6 @@ public class Hook extends AbstractAuditableCustom {
|
|||||||
return templateId;
|
return templateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<HookConfiguration> getHookConfig() {
|
|
||||||
return this.config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Object> update(final JsonCommand command) {
|
public Map<String, Object> update(final JsonCommand command) {
|
||||||
|
|
||||||
final Map<String, Object> actualChanges = new LinkedHashMap<>(5);
|
final Map<String, Object> actualChanges = new LinkedHashMap<>(5);
|
||||||
@@ -201,8 +195,4 @@ public class Hook extends AbstractAuditableCustom {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateUgdTemplate(final Template ugdTemplate) {
|
|
||||||
this.ugdTemplate = ugdTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-29
@@ -23,10 +23,18 @@ import javax.persistence.Entity;
|
|||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "m_hook_configuration")
|
@Table(name = "m_hook_configuration")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class HookConfiguration extends AbstractPersistableCustom {
|
public class HookConfiguration extends AbstractPersistableCustom {
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
@ManyToOne(optional = false)
|
||||||
@@ -43,38 +51,11 @@ public class HookConfiguration extends AbstractPersistableCustom {
|
|||||||
private String fieldValue;
|
private String fieldValue;
|
||||||
|
|
||||||
public static HookConfiguration createNewWithoutHook(final String fieldType, final String fieldName, final String fieldValue) {
|
public static HookConfiguration createNewWithoutHook(final String fieldType, final String fieldName, final String fieldValue) {
|
||||||
return new HookConfiguration(null, fieldType, fieldName, fieldValue);
|
return new HookConfiguration().setFieldType(fieldType).setFieldName(fieldName).setFieldValue(fieldValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HookConfiguration createNew(final Hook hook, final String fieldType, final String fieldName, final String fieldValue) {
|
public static HookConfiguration createNew(final Hook hook, final String fieldType, final String fieldName, final String fieldValue) {
|
||||||
return new HookConfiguration(hook, fieldType, fieldName, fieldValue);
|
return new HookConfiguration().setHook(hook).setFieldType(fieldType).setFieldName(fieldName).setFieldValue(fieldValue);
|
||||||
}
|
|
||||||
|
|
||||||
protected HookConfiguration() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
private HookConfiguration(final Hook hook, final String fieldType, final String fieldName, final String fieldValue) {
|
|
||||||
this.hook = hook;
|
|
||||||
this.fieldType = fieldType;
|
|
||||||
this.fieldName = fieldName;
|
|
||||||
this.fieldValue = fieldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFieldName() {
|
|
||||||
return this.fieldName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFieldType() {
|
|
||||||
return this.fieldType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFieldValue() {
|
|
||||||
return this.fieldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(final Hook hook) {
|
|
||||||
this.hook = hook;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-15
@@ -23,10 +23,18 @@ import javax.persistence.Entity;
|
|||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "m_hook_registered_events")
|
@Table(name = "m_hook_registered_events")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class HookResource extends AbstractPersistableCustom {
|
public class HookResource extends AbstractPersistableCustom {
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
@ManyToOne(optional = false)
|
||||||
@@ -39,21 +47,7 @@ public class HookResource extends AbstractPersistableCustom {
|
|||||||
@Column(name = "action_name", nullable = false, length = 45)
|
@Column(name = "action_name", nullable = false, length = 45)
|
||||||
private String actionName;
|
private String actionName;
|
||||||
|
|
||||||
protected HookResource() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HookResource createNewWithoutHook(final String entityName, final String actionName) {
|
public static HookResource createNewWithoutHook(final String entityName, final String actionName) {
|
||||||
return new HookResource(null, entityName, actionName);
|
return new HookResource().setEntityName(entityName).setActionName(actionName);
|
||||||
}
|
|
||||||
|
|
||||||
private HookResource(final Hook hook, final String entityName, final String actionName) {
|
|
||||||
this.hook = hook;
|
|
||||||
this.entityName = entityName;
|
|
||||||
this.actionName = actionName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(final Hook hook) {
|
|
||||||
this.hook = hook;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-13
@@ -28,13 +28,21 @@ import javax.persistence.Entity;
|
|||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "m_hook_templates")
|
@Table(name = "m_hook_templates")
|
||||||
public class HookTemplate extends AbstractPersistableCustom {
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public final class HookTemplate extends AbstractPersistableCustom {
|
||||||
|
|
||||||
@Column(name = "name", nullable = false, length = 100)
|
@Column(name = "name", nullable = false, length = 100)
|
||||||
private String name;
|
private String name;
|
||||||
@@ -51,20 +59,8 @@ public class HookTemplate extends AbstractPersistableCustom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HookTemplate() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HookTemplate fromJson(final JsonCommand command) {
|
public static HookTemplate fromJson(final JsonCommand command) {
|
||||||
final String name = command.stringValueOfParameterNamed(nameParamName);
|
final String name = command.stringValueOfParameterNamed(nameParamName);
|
||||||
return new HookTemplate(name);
|
return new HookTemplate(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Schema> getSchema() {
|
|
||||||
return this.fields;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-16
@@ -23,10 +23,18 @@ import javax.persistence.Entity;
|
|||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "m_hook_schema")
|
@Table(name = "m_hook_schema")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class Schema extends AbstractPersistableCustom {
|
public class Schema extends AbstractPersistableCustom {
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
@ManyToOne(optional = false)
|
||||||
@@ -45,20 +53,4 @@ public class Schema extends AbstractPersistableCustom {
|
|||||||
@Column(name = "optional", nullable = false)
|
@Column(name = "optional", nullable = false)
|
||||||
private boolean optional = false;
|
private boolean optional = false;
|
||||||
|
|
||||||
public Schema() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFieldName() {
|
|
||||||
return this.fieldName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFieldType() {
|
|
||||||
return this.fieldType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOptional() {
|
|
||||||
return this.optional;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@ public class ElasticSearchHookProcessor implements HookProcessor {
|
|||||||
public void process(final Hook hook, final String payload, final String entityName, final String actionName,
|
public void process(final Hook hook, final String payload, final String entityName, final String actionName,
|
||||||
final FineractContext context) {
|
final FineractContext context) {
|
||||||
|
|
||||||
final Set<HookConfiguration> config = hook.getHookConfig();
|
final Set<HookConfiguration> config = hook.getConfig();
|
||||||
|
|
||||||
String url = "";
|
String url = "";
|
||||||
String contentType = "";
|
String contentType = "";
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ public class HookProcessorProvider implements ApplicationContextAware {
|
|||||||
|
|
||||||
public HookProcessor getProcessor(final Hook hook) {
|
public HookProcessor getProcessor(final Hook hook) {
|
||||||
HookProcessor processor;
|
HookProcessor processor;
|
||||||
final String templateName = hook.getHookTemplate().getName();
|
final String templateName = hook.getTemplate().getName();
|
||||||
if (templateName.equalsIgnoreCase(smsTemplateName)) {
|
if (templateName.equalsIgnoreCase(smsTemplateName)) {
|
||||||
processor = this.applicationContext.getBean("twilioHookProcessor", TwilioHookProcessor.class);
|
processor = this.applicationContext.getBean("twilioHookProcessor", TwilioHookProcessor.class);
|
||||||
} else if (templateName.equals(webTemplateName)) {
|
} else if (templateName.equals(webTemplateName)) {
|
||||||
|
|||||||
+1
-1
@@ -60,7 +60,7 @@ public class MessageGatewayHookProcessor implements HookProcessor {
|
|||||||
public void process(final Hook hook, final String payload, final String entityName, final String actionName,
|
public void process(final Hook hook, final String payload, final String entityName, final String actionName,
|
||||||
final FineractContext context) throws IOException {
|
final FineractContext context) throws IOException {
|
||||||
|
|
||||||
final Set<HookConfiguration> config = hook.getHookConfig();
|
final Set<HookConfiguration> config = hook.getConfig();
|
||||||
|
|
||||||
Integer SMSProviderId = null;
|
Integer SMSProviderId = null;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ public class TwilioHookProcessor implements HookProcessor {
|
|||||||
public void process(final Hook hook, final String payload, final String entityName, final String actionName,
|
public void process(final Hook hook, final String payload, final String entityName, final String actionName,
|
||||||
final FineractContext context) throws IOException {
|
final FineractContext context) throws IOException {
|
||||||
|
|
||||||
final SmsProviderData smsProviderData = new SmsProviderData(hook.getHookConfig());
|
final SmsProviderData smsProviderData = new SmsProviderData(hook.getConfig());
|
||||||
|
|
||||||
sendRequest(smsProviderData, payload, entityName, actionName, hook, context);
|
sendRequest(smsProviderData, payload, entityName, actionName, hook, context);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ public class WebHookProcessor implements HookProcessor {
|
|||||||
public void process(final Hook hook, final String payload, final String entityName, final String actionName,
|
public void process(final Hook hook, final String payload, final String entityName, final String actionName,
|
||||||
final FineractContext context) {
|
final FineractContext context) {
|
||||||
|
|
||||||
final Set<HookConfiguration> config = hook.getHookConfig();
|
final Set<HookConfiguration> config = hook.getConfig();
|
||||||
|
|
||||||
String url = "";
|
String url = "";
|
||||||
String contentType = "";
|
String contentType = "";
|
||||||
|
|||||||
+4
-4
@@ -130,7 +130,7 @@ public class HookWritePlatformServiceJpaRepositoryImpl implements HookWritePlatf
|
|||||||
this.fromApiJsonDeserializer.validateForUpdate(command.json());
|
this.fromApiJsonDeserializer.validateForUpdate(command.json());
|
||||||
|
|
||||||
final Hook hook = retrieveHookBy(hookId);
|
final Hook hook = retrieveHookBy(hookId);
|
||||||
final HookTemplate template = hook.getHookTemplate();
|
final HookTemplate template = hook.getTemplate();
|
||||||
final Map<String, Object> changes = hook.update(command);
|
final Map<String, Object> changes = hook.update(command);
|
||||||
|
|
||||||
if (!changes.isEmpty()) {
|
if (!changes.isEmpty()) {
|
||||||
@@ -142,7 +142,7 @@ public class HookWritePlatformServiceJpaRepositoryImpl implements HookWritePlatf
|
|||||||
changes.remove(templateIdParamName);
|
changes.remove(templateIdParamName);
|
||||||
throw new TemplateNotFoundException(ugdTemplateId);
|
throw new TemplateNotFoundException(ugdTemplateId);
|
||||||
}
|
}
|
||||||
hook.updateUgdTemplate(ugdTemplate);
|
hook.setUgdTemplate(ugdTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changes.containsKey(eventsParamName)) {
|
if (changes.containsKey(eventsParamName)) {
|
||||||
@@ -211,7 +211,7 @@ public class HookWritePlatformServiceJpaRepositoryImpl implements HookWritePlatf
|
|||||||
private Set<HookConfiguration> assembleConfig(final Map<String, String> hookConfig, final HookTemplate template) {
|
private Set<HookConfiguration> assembleConfig(final Map<String, String> hookConfig, final HookTemplate template) {
|
||||||
|
|
||||||
final Set<HookConfiguration> configuration = new HashSet<>();
|
final Set<HookConfiguration> configuration = new HashSet<>();
|
||||||
final Set<Schema> fields = template.getSchema();
|
final Set<Schema> fields = template.getFields();
|
||||||
|
|
||||||
for (final Map.Entry<String, String> configEntry : hookConfig.entrySet()) {
|
for (final Map.Entry<String, String> configEntry : hookConfig.entrySet()) {
|
||||||
for (final Schema field : fields) {
|
for (final Schema field : fields) {
|
||||||
@@ -282,7 +282,7 @@ public class HookWritePlatformServiceJpaRepositoryImpl implements HookWritePlatf
|
|||||||
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(errorMessage);
|
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Set<Schema> fields = template.getSchema();
|
final Set<Schema> fields = template.getFields();
|
||||||
for (final Schema field : fields) {
|
for (final Schema field : fields) {
|
||||||
if (!field.isOptional()) {
|
if (!field.isOptional()) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user