SUPPORT-9422: edit for new format
This commit is contained in:
parent
b1e33efd60
commit
0df57ed5a7
13 changed files with 44 additions and 27 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
package ervu_business_metrics.dao;
|
package ervu_business_metrics.dao;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -66,11 +67,11 @@ public abstract class AbstractDataDao<T extends UpdatableRecord<T>> {
|
||||||
.fetch(selectField);
|
.fetch(selectField);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <V, F> void setFieldByField(Field<V> targetField, V value, Field<F> whereField,
|
protected <V, F> void setFieldWhereIn(Field<V> targetField, V value, Field<F> whereField,
|
||||||
F whereValue) {
|
Collection<F> whereValues) {
|
||||||
dsl.update(getTable())
|
dsl.update(getTable())
|
||||||
.set(targetField, value)
|
.set(targetField, value)
|
||||||
.where(whereField.eq(whereValue))
|
.where(whereField.in(whereValues))
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ public class AccountDataDao extends AbstractDataDao<AccountRecord> {
|
||||||
return getValuesByField(Tables.ACCOUNT.ID, Tables.ACCOUNT.PERSON_ID, personId);
|
return getValuesByField(Tables.ACCOUNT.ID, Tables.ACCOUNT.PERSON_ID, personId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActiveStatus(String id, boolean active) {
|
public void setActiveStatus(List<String> ids, boolean active) {
|
||||||
setFieldByField(Tables.ACCOUNT.ACTIVE, active, Tables.ACCOUNT.ID, id);
|
setFieldWhereIn(Tables.ACCOUNT.ACTIVE, active, Tables.ACCOUNT.ID, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteByIds(List<String> ids) {
|
public void deleteByIds(List<String> ids) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package ervu_business_metrics.dao;
|
package ervu_business_metrics.dao;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import ervu_business_metrics.config.KafkaEnabledCondition;
|
import ervu_business_metrics.config.KafkaEnabledCondition;
|
||||||
import org.jooq.DSLContext;
|
import org.jooq.DSLContext;
|
||||||
import org.jooq.Table;
|
import org.jooq.Table;
|
||||||
|
|
@ -20,8 +22,8 @@ public class DomainDataDao extends AbstractDataDao<DomainRecord> {
|
||||||
super(dsl);
|
super(dsl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActiveStatus(String id , boolean active){
|
public void setActiveStatus(List<String> ids , boolean active){
|
||||||
setFieldByField(Tables.DOMAIN.ACTIVE, active, Tables.DOMAIN.ID, id);
|
setFieldWhereIn(Tables.DOMAIN.ACTIVE, active, Tables.DOMAIN.ID, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package ervu_business_metrics.dao;
|
package ervu_business_metrics.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import ervu_business_metrics.config.KafkaEnabledCondition;
|
import ervu_business_metrics.config.KafkaEnabledCondition;
|
||||||
import org.jooq.DSLContext;
|
import org.jooq.DSLContext;
|
||||||
import org.jooq.Table;
|
import org.jooq.Table;
|
||||||
|
|
@ -19,8 +21,8 @@ public class PersonDataDao extends AbstractDataDao<PersonRecord> {
|
||||||
super(dsl);
|
super(dsl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActiveStatus(String id , boolean active){
|
public void setActiveStatus(List<String> ids , boolean active){
|
||||||
setFieldByField(Tables.PERSON.ACTIVE, active, Tables.PERSON.ID, id);
|
setFieldWhereIn(Tables.PERSON.ACTIVE, active, Tables.PERSON.ID, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package ervu_business_metrics.dao;
|
package ervu_business_metrics.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import ervu_business_metrics.config.KafkaEnabledCondition;
|
import ervu_business_metrics.config.KafkaEnabledCondition;
|
||||||
import org.jooq.DSLContext;
|
import org.jooq.DSLContext;
|
||||||
import org.jooq.Table;
|
import org.jooq.Table;
|
||||||
|
|
@ -19,8 +21,8 @@ public class RoleDataDao extends AbstractDataDao<RoleRecord> {
|
||||||
super(dsl);
|
super(dsl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActiveStatus(String id , boolean active){
|
public void setActiveStatus(List<String> ids , boolean active){
|
||||||
setFieldByField(Tables.ROLE.ACTIVE, active, Tables.ROLE.ID, id);
|
setFieldWhereIn(Tables.ROLE.ACTIVE, active, Tables.ROLE.ID, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
package ervu_business_metrics.kafka.model;
|
package ervu_business_metrics.kafka.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import ervu_business_metrics.model.ReferenceEntity;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adel Kalimullin
|
* @author Adel Kalimullin
|
||||||
|
|
@ -9,13 +10,13 @@ import ervu_business_metrics.model.ReferenceEntity;
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class ChangeActiveMessage {
|
public class ChangeActiveMessage {
|
||||||
private boolean success;
|
private boolean success;
|
||||||
private ReferenceEntity data;
|
private List<String> data;
|
||||||
|
|
||||||
public ReferenceEntity getData() {
|
public List<String> getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(ReferenceEntity data) {
|
public void setData(List<String> data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import org.springframework.context.annotation.DependsOn;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
|
|
@ -102,13 +103,13 @@ public class IdmDirectoriesService {
|
||||||
ChangeActiveMessage.class
|
ChangeActiveMessage.class
|
||||||
);
|
);
|
||||||
|
|
||||||
if (changeActiveMessage.isSuccess() && changeActiveMessage.getData() != null) {
|
if (changeActiveMessage.isSuccess() && !CollectionUtils.isEmpty(changeActiveMessage.getData())) {
|
||||||
DataProcessor<T, ?> processor = (DataProcessor<T, ?>) dataProcessors.get(entityClass);
|
DataProcessor<T, ?> processor = (DataProcessor<T, ?>) dataProcessors.get(entityClass);
|
||||||
if (processor == null) {
|
if (processor == null) {
|
||||||
throw new IllegalStateException("No processor found for " + entityClass.getSimpleName());
|
throw new IllegalStateException("No processor found for " + entityClass.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
processor.changeActiveStatus(changeActiveMessage.getData().getId(), active);
|
processor.changeActiveStatus(changeActiveMessage.getData(), active);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
package ervu_business_metrics.service.processor;
|
package ervu_business_metrics.service.processor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adel Kalimullin
|
* @author Adel Kalimullin
|
||||||
*/
|
*/
|
||||||
public interface DataProcessor<T, R> {
|
public interface DataProcessor<T, R> {
|
||||||
void upsertData(T data);
|
void upsertData(T data);
|
||||||
|
|
||||||
void changeActiveStatus(String id, boolean active);
|
void changeActiveStatus(List<String> ids, boolean active);
|
||||||
|
|
||||||
Class<T> getType();
|
Class<T> getType();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ public class AccountDataProcessor implements DataProcessor<AccountData, AccountR
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeActiveStatus(String id, boolean active) {
|
public void changeActiveStatus(List<String> ids, boolean active) {
|
||||||
dao.setActiveStatus(id, active);
|
dao.setActiveStatus(ids, active);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ public class AccountRoleDataProcessor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeActiveStatus(String id, boolean active) {
|
public void changeActiveStatus(List<String> ids, boolean active) {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package ervu_business_metrics.service.processor.impl;
|
package ervu_business_metrics.service.processor.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import ervu_business_metrics.config.KafkaEnabledCondition;
|
import ervu_business_metrics.config.KafkaEnabledCondition;
|
||||||
import ervu_business_metrics.dao.DomainDataDao;
|
import ervu_business_metrics.dao.DomainDataDao;
|
||||||
import ervu_business_metrics.model.idm.DomainData;
|
import ervu_business_metrics.model.idm.DomainData;
|
||||||
|
|
@ -27,8 +29,8 @@ public class DomainDataProcessor implements DataProcessor<DomainData, DomainReco
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeActiveStatus(String id, boolean active) {
|
public void changeActiveStatus(List<String> ids, boolean active) {
|
||||||
dao.setActiveStatus(id, active);
|
dao.setActiveStatus(ids, active);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package ervu_business_metrics.service.processor.impl;
|
package ervu_business_metrics.service.processor.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import ervu_business_metrics.config.KafkaEnabledCondition;
|
import ervu_business_metrics.config.KafkaEnabledCondition;
|
||||||
import ervu_business_metrics.dao.PersonDataDao;
|
import ervu_business_metrics.dao.PersonDataDao;
|
||||||
import ervu_business_metrics.model.idm.PersonData;
|
import ervu_business_metrics.model.idm.PersonData;
|
||||||
|
|
@ -34,8 +36,8 @@ public class PersonDataProcessor implements DataProcessor<PersonData, PersonReco
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeActiveStatus(String id, boolean active) {
|
public void changeActiveStatus(List<String> ids, boolean active) {
|
||||||
dao.setActiveStatus(id, active);
|
dao.setActiveStatus(ids, active);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package ervu_business_metrics.service.processor.impl;
|
package ervu_business_metrics.service.processor.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import ervu_business_metrics.config.KafkaEnabledCondition;
|
import ervu_business_metrics.config.KafkaEnabledCondition;
|
||||||
import ervu_business_metrics.dao.RoleDataDao;
|
import ervu_business_metrics.dao.RoleDataDao;
|
||||||
import ervu_business_metrics.model.idm.RoleData;
|
import ervu_business_metrics.model.idm.RoleData;
|
||||||
|
|
@ -28,8 +30,8 @@ public class RoleDataProcessor implements DataProcessor<RoleData, RoleRecord> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeActiveStatus(String id, boolean active) {
|
public void changeActiveStatus(List<String> ids, boolean active) {
|
||||||
dao.setActiveStatus(id, active);
|
dao.setActiveStatus(ids, active);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue