Skip to content

Commit

Permalink
gh-2909 duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
GCHQDev404 committed Mar 3, 2023
1 parent bcd57a5 commit dca282e
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@
import uk.gov.gchq.gaffer.jobtracker.JobDetail;
import uk.gov.gchq.gaffer.jobtracker.Repeat;
import uk.gov.gchq.gaffer.named.operation.AddNamedOperation;
import uk.gov.gchq.gaffer.named.operation.AddNamedOperation;
import uk.gov.gchq.gaffer.named.view.AddNamedView;
import uk.gov.gchq.gaffer.named.view.AddNamedView;
import uk.gov.gchq.gaffer.operation.Operation;
import uk.gov.gchq.gaffer.operation.OperationChain;
Expand Down
10 changes: 0 additions & 10 deletions core/store/src/main/java/uk/gov/gchq/gaffer/store/Store.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@
*/
public abstract class Store {
private static final Logger LOGGER = LoggerFactory.getLogger(Store.class);
public static final String ADD_GRAPH_DECLARATIONS = "gaffer.federatedstore.addgraph.declarations";
private final Class<? extends Serialiser> requiredParentSerialiserClass;
private final Map<Class<? extends Operation>, OperationHandler> operationHandlers = new LinkedHashMap<>();
protected final List<OperationChainOptimiser> opChainOptimisers = new ArrayList<>();
Expand Down Expand Up @@ -1102,15 +1101,6 @@ private void addConfiguredOperationHandlers() {
addOperationHandler(definition.getOperation(), definition.getHandler());
}
}

if (properties.containsKey(ADD_GRAPH_DECLARATIONS)) {
final String json = properties.get(ADD_GRAPH_DECLARATIONS);
final OperationDeclarations operationDeclarations = OperationDeclarations.fromJson(json);
for (final OperationDeclaration definition : operationDeclarations.getOperations()) {
addOperationHandler(definition.getOperation(), definition.getHandler());
}
}

}

protected void startCacheServiceLoader(final StoreProperties properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class StoreProperties implements Cloneable {

public static final String STORE_PROPERTIES_CLASS = "gaffer.store.properties.class";
public static final String OPERATION_DECLARATIONS = "gaffer.store.operation.declarations";
public static final String OPERATION_DECLARATIONS_JSON = "gaffer.store.operation.declarations.json";

public static final String JOB_TRACKER_ENABLED = "gaffer.store.job.tracker.enabled";

Expand Down Expand Up @@ -275,18 +276,21 @@ public void merge(final StoreProperties properties) {
*/
@JsonIgnore
public OperationDeclarations getOperationDeclarations() {
OperationDeclarations declarations = null;
OperationDeclarations.Builder declarations = new OperationDeclarations.Builder();

final String declarationsPaths = get(StoreProperties.OPERATION_DECLARATIONS);
if (null != declarationsPaths) {
declarations = OperationDeclarations.fromPaths(declarationsPaths);
OperationDeclarations.fromPaths(declarationsPaths).getOperations()
.forEach(d -> declarations.declaration(d));
}

if (null == declarations) {
declarations = new OperationDeclarations.Builder().build();
if (containsKey(OPERATION_DECLARATIONS_JSON)) {
final String json = get(OPERATION_DECLARATIONS_JSON);
OperationDeclarations.fromJson(json).getOperations()
.forEach(d -> declarations.declaration(d));
}

return declarations;
return declarations.build();
}

public String getStoreClass() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,6 @@ public static OperationDeclarations fromJson(final byte[] json) {
}
}

public static OperationDeclarations fromJson(final String json) {
try {
return JSONSerialiser.deserialise(json, OperationDeclarations.class);
} catch (final SerialisationException e) {
throw new GafferRuntimeException("Failed to load element definitions from JSON String. Due to " + e.getMessage(), e);
}
}

public static OperationDeclarations fromJson(final InputStream inputStream) {
try {
return JSONSerialiser.deserialise(inputStream, OperationDeclarations.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
import static uk.gov.gchq.gaffer.federatedstore.FederatedGraphStorage.USER_IS_ATTEMPTING_TO_OVERWRITE;
import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.SCHEMA_EDGE_BASIC_JSON;
import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.loadSchemaFromJson;
import static uk.gov.gchq.gaffer.store.Store.ADD_GRAPH_DECLARATIONS;
import static uk.gov.gchq.gaffer.store.StoreProperties.OPERATION_DECLARATIONS_JSON;
import static uk.gov.gchq.gaffer.user.StoreUser.authUser;
import static uk.gov.gchq.gaffer.user.StoreUser.blankUser;
import static uk.gov.gchq.gaffer.user.StoreUser.testUser;
Expand Down Expand Up @@ -443,7 +443,7 @@ public void shouldAddGraphWithHandler() throws Exception {

final AccumuloProperties clone = PROPERTIES.clone();

clone.set(ADD_GRAPH_DECLARATIONS, new String(JSONSerialiser.serialise(new OperationDeclarations.Builder()
clone.set(OPERATION_DECLARATIONS_JSON, new String(JSONSerialiser.serialise(new OperationDeclarations.Builder()
.declaration(new OperationDeclaration.Builder()
.handler(new TestErrorHandler())
.operation(GetAllElements.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import org.junit.platform.suite.api.ConfigurationParameter;
import org.junit.platform.suite.api.ExcludeClassNamePatterns;
import org.junit.platform.suite.api.IncludeClassNamePatterns;

import uk.gov.gchq.gaffer.commonutil.StreamUtil;
import uk.gov.gchq.gaffer.integration.AbstractStoreITs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@

import uk.gov.gchq.gaffer.commonutil.StreamUtil;
import uk.gov.gchq.gaffer.graph.Graph;
import uk.gov.gchq.gaffer.named.operation.AddNamedOperation;
import uk.gov.gchq.gaffer.named.operation.DeleteNamedOperation;
import uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations;
import uk.gov.gchq.gaffer.named.operation.NamedOperation;
import uk.gov.gchq.gaffer.named.view.AddNamedView;
import uk.gov.gchq.gaffer.named.view.DeleteNamedView;
import uk.gov.gchq.gaffer.named.view.GetAllNamedViews;
import uk.gov.gchq.gaffer.operation.Operation;
import uk.gov.gchq.gaffer.operation.OperationChain;
import uk.gov.gchq.gaffer.operation.OperationChainDAO;
Expand Down

0 comments on commit dca282e

Please sign in to comment.