[CST-11887] refactoring

This commit is contained in:
eskander
2023-09-21 18:27:27 +03:00
parent 68609cc1fc
commit 224b94be95
10 changed files with 36 additions and 36 deletions

View File

@@ -53,8 +53,8 @@ public class NotifyServiceEntity implements ReloadableEntity<Integer> {
@OneToMany(mappedBy = "notifyService")
private List<NotifyServiceOutboundPattern> outboundPatterns;
@Column(name = "status")
private Boolean status = true;
@Column(name = "enabled")
private Boolean enabled = true;
public void setId(Integer id) {
this.id = id;
@@ -122,11 +122,11 @@ public class NotifyServiceEntity implements ReloadableEntity<Integer> {
return id;
}
public Boolean getStatus() {
return status;
public Boolean isEnabled() {
return enabled;
}
public void setStatus(boolean status) {
this.status = status;
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}

View File

@@ -7,7 +7,7 @@
--
-----------------------------------------------------------------------------------
-- edit notifyservice table add status column
-- edit notifyservice table add enabled column
-----------------------------------------------------------------------------------
ALTER TABLE notifyservice ADD COLUMN status BOOLEAN DEFAULT TRUE NOT NULL;
ALTER TABLE notifyservice ADD COLUMN enabled BOOLEAN DEFAULT TRUE NOT NULL;

View File

@@ -7,7 +7,7 @@
--
-----------------------------------------------------------------------------------
-- edit notifyservice table add status column
-- edit notifyservice table add enabled column
-----------------------------------------------------------------------------------
ALTER TABLE notifyservice ADD COLUMN status BOOLEAN DEFAULT TRUE NOT NULL;
ALTER TABLE notifyservice ADD COLUMN enabled BOOLEAN DEFAULT TRUE NOT NULL;

View File

@@ -125,8 +125,8 @@ public class NotifyServiceBuilder extends AbstractBuilder<NotifyServiceEntity, N
return this;
}
public NotifyServiceBuilder withStatus(boolean status) {
notifyServiceEntity.setStatus(status);
public NotifyServiceBuilder isEnabled(boolean enabled) {
notifyServiceEntity.setEnabled(enabled);
return this;
}

View File

@@ -37,7 +37,7 @@ public class NotifyServiceConverter implements DSpaceConverter<NotifyServiceEnti
notifyServiceRest.setDescription(obj.getDescription());
notifyServiceRest.setUrl(obj.getUrl());
notifyServiceRest.setLdnUrl(obj.getLdnUrl());
notifyServiceRest.setStatus(obj.getStatus());
notifyServiceRest.setEnabled(obj.isEnabled());
if (obj.getInboundPatterns() != null) {
notifyServiceRest.setNotifyServiceInboundPatterns(

View File

@@ -26,7 +26,7 @@ public class NotifyServiceRest extends BaseObjectRest<Integer> {
private String description;
private String url;
private String ldnUrl;
private boolean status;
private boolean enabled;
private List<NotifyServiceInboundPatternRest> notifyServiceInboundPatterns;
private List<NotifyServiceOutboundPatternRest> notifyServiceOutboundPatterns;
@@ -78,12 +78,12 @@ public class NotifyServiceRest extends BaseObjectRest<Integer> {
this.ldnUrl = ldnUrl;
}
public boolean getStatus() {
return status;
public boolean isEnabled() {
return enabled;
}
public void setStatus(boolean status) {
this.status = status;
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public List<NotifyServiceInboundPatternRest> getNotifyServiceInboundPatterns() {
return notifyServiceInboundPatterns;

View File

@@ -87,7 +87,7 @@ public class NotifyServiceRestRepository extends DSpaceRestRepository<NotifyServ
notifyServiceEntity.setDescription(notifyServiceRest.getDescription());
notifyServiceEntity.setUrl(notifyServiceRest.getUrl());
notifyServiceEntity.setLdnUrl(notifyServiceRest.getLdnUrl());
notifyServiceEntity.setStatus(notifyServiceRest.getStatus());
notifyServiceEntity.setEnabled(notifyServiceRest.isEnabled());
notifyService.update(context, notifyServiceEntity);
return converter.toRest(notifyServiceEntity, utils.obtainProjection());

View File

@@ -19,19 +19,19 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Implementation for NotifyService Status Replace patches.
* Implementation for NotifyService Enabled Replace patches.
*
* Example: <code>
* curl -X PATCH http://${dspace.server.url}/api/ldn/ldnservices/<:id-notifyService> -H "
* Content-Type: application/json" -d '
* [{
* "op": "replace",
* "path": "/status"
* "path": "/enabled"
* }]'
* </code>
*/
@Component
public class NotifyServiceStatusReplaceOperation extends PatchOperation<NotifyServiceEntity> {
public class NotifyServiceEnabledReplaceOperation extends PatchOperation<NotifyServiceEntity> {
@Autowired
private NotifyService notifyService;
@@ -39,21 +39,21 @@ public class NotifyServiceStatusReplaceOperation extends PatchOperation<NotifySe
@Autowired
private NotifyServicePatchUtils notifyServicePatchUtils;
private static final String OPERATION_PATH = "/status";
private static final String OPERATION_PATH = "/enabled";
@Override
public NotifyServiceEntity perform(Context context, NotifyServiceEntity notifyServiceEntity, Operation operation)
throws SQLException {
checkOperationValue(operation.getValue());
Boolean status = getBooleanOperationValue(operation.getValue());
Boolean enabled = getBooleanOperationValue(operation.getValue());
if (supports(notifyServiceEntity, operation)) {
notifyServiceEntity.setStatus(status);
notifyServiceEntity.setEnabled(enabled);
notifyService.update(context, notifyServiceEntity);
return notifyServiceEntity;
} else {
throw new DSpaceBadRequestException(
"NotifyServiceStatusReplaceOperation does not support this operation");
"NotifyServiceEnabledReplaceOperation does not support this operation");
}
}

View File

@@ -153,7 +153,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
notifyServiceRest.setDescription("service description");
notifyServiceRest.setUrl("service url");
notifyServiceRest.setLdnUrl("service ldn url");
notifyServiceRest.setStatus(false);
notifyServiceRest.setEnabled(false);
AtomicReference<Integer> idRef = new AtomicReference<Integer>();
String authToken = getAuthToken(admin.getEmail(), password);
@@ -240,7 +240,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
.withName("service name")
.withUrl("service url")
.withLdnUrl("service ldn url")
.withStatus(false)
.isEnabled(false)
.build();
context.restoreAuthSystemState();
@@ -330,7 +330,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
.withDescription("service description")
.withUrl("service url")
.withLdnUrl("service ldn url")
.withStatus(false)
.isEnabled(false)
.build();
context.restoreAuthSystemState();
@@ -3199,12 +3199,12 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
.withDescription("service description")
.withUrl("service url")
.withLdnUrl("service ldn url")
.withStatus(true)
.isEnabled(true)
.build();
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("/status", "false");
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("/enabled", "false");
ops.add(inboundReplaceOperation);
String patchBody = getPatchContent(ops);
@@ -3234,7 +3234,7 @@ public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegration
context.restoreAuthSystemState();
List<Operation> ops = new ArrayList<Operation>();
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("/status", "test");
ReplaceOperation inboundReplaceOperation = new ReplaceOperation("/enabled", "test");
ops.add(inboundReplaceOperation);
String patchBody = getPatchContent(ops);

View File

@@ -38,13 +38,13 @@ public class NotifyServiceMatcher {
}
public static Matcher<? super Object> matchNotifyService(String name, String description, String url,
String ldnUrl, boolean status) {
String ldnUrl, boolean enabled) {
return allOf(
hasJsonPath("$.name", is(name)),
hasJsonPath("$.description", is(description)),
hasJsonPath("$.url", is(url)),
hasJsonPath("$.ldnUrl", is(ldnUrl)),
hasJsonPath("$.status", is(status)),
hasJsonPath("$.enabled", is(enabled)),
hasJsonPath("$._links.self.href", containsString("/api/ldn/ldnservices/"))
);
}
@@ -60,10 +60,10 @@ public class NotifyServiceMatcher {
}
public static Matcher<? super Object> matchNotifyService(int id, String name, String description,
String url, String ldnUrl, boolean status) {
String url, String ldnUrl, boolean enabled) {
return allOf(
hasJsonPath("$.id", is(id)),
matchNotifyService(name, description, url, ldnUrl, status),
matchNotifyService(name, description, url, ldnUrl, enabled),
hasJsonPath("$._links.self.href", startsWith(REST_SERVER_URL)),
hasJsonPath("$._links.self.href", endsWith("/api/ldn/ldnservices/" + id))
);