/*
* Copyright 2013, The Sporting Exchange Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright 2013, The Sporting Exchange Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright 2013, The Sporting Exchange Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Generated from syncServiceExecutableResolver.ftl
package com.betfair.testingservice.v1;
import com.betfair.testingservice.v1.co.*;
import com.betfair.testingservice.v1.to.*;
import com.betfair.testingservice.v1.enumerations.*;
import com.betfair.testingservice.v1.exception.*;
import com.betfair.cougar.core.api.ev.ConnectedResponse;
import com.betfair.cougar.api.ExecutionContext;
import com.betfair.cougar.api.RequestContext;
import com.betfair.cougar.api.fault.CougarApplicationException;
import com.betfair.cougar.core.api.exception.CougarException;
import com.betfair.cougar.core.api.exception.CougarServiceException;
import com.betfair.cougar.core.api.exception.ServerFaultCode;
import com.betfair.cougar.core.api.ev.Executable;
import com.betfair.cougar.core.api.ev.ExecutableResolver;
import com.betfair.cougar.core.api.ev.ExecutionObserver;
import com.betfair.cougar.core.api.ev.ExecutionResult;
import com.betfair.cougar.core.api.ev.ExecutionVenue;
import com.betfair.cougar.core.api.ev.OperationKey;
import com.betfair.cougar.core.api.ev.TimeConstraints;
import java.util.*;
/**
* Resolves Executables for all operations in the synchronous TestingService.
*/
@SuppressWarnings("all")
public class TestingSyncServiceExecutableResolver implements ExecutableResolver {
private Map<OperationKey, Executable> executableMap = new HashMap<OperationKey, Executable>();
private TestingService service;
public TestingSyncServiceExecutableResolver() {
executableMap.put(TestingServiceDefinition.refreshAllCachesKey,
new Executable() {
@Override
public void execute(ExecutionContext ctx, OperationKey key,
Object[] args, ExecutionObserver observer,
ExecutionVenue executionVenue, TimeConstraints timeConstraints) {
try {
CallResponse result = service.refreshAllCaches((RequestContext)ctx, timeConstraints);
observer.onResult(new ExecutionResult(result));
} catch (CougarException ce) {
observer.onResult(new ExecutionResult(ce));
} catch (TestingException ex) {
observer.onResult(new ExecutionResult((CougarApplicationException)ex));
};
}
});
executableMap.put(TestingServiceDefinition.refreshCacheKey,
new Executable() {
@Override
public void execute(ExecutionContext ctx, OperationKey key,
Object[] args, ExecutionObserver observer,
ExecutionVenue executionVenue, TimeConstraints timeConstraints) {
try {
CallResponse result = service.refreshCache((RequestContext)ctx, (String)args[0], timeConstraints);
observer.onResult(new ExecutionResult(result));
} catch (CougarException ce) {
observer.onResult(new ExecutionResult(ce));
} catch (TestingException ex) {
observer.onResult(new ExecutionResult((CougarApplicationException)ex));
};
}
});
executableMap.put(TestingServiceDefinition.getIDDKey,
new Executable() {
@Override
public void execute(ExecutionContext ctx, OperationKey key,
Object[] args, ExecutionObserver observer,
ExecutionVenue executionVenue, TimeConstraints timeConstraints) {
try {
IDD result = service.getIDD((RequestContext)ctx, (String)args[0], timeConstraints);
observer.onResult(new ExecutionResult(result));
} catch (CougarException ce) {
observer.onResult(new ExecutionResult(ce));
} catch (TestingException ex) {
observer.onResult(new ExecutionResult((CougarApplicationException)ex));
};
}
});
executableMap.put(TestingServiceDefinition.getLogEntriesKey,
new Executable() {
@Override
public void execute(ExecutionContext ctx, OperationKey key,
Object[] args, ExecutionObserver observer,
ExecutionVenue executionVenue, TimeConstraints timeConstraints) {
try {
LogFileResponse result = service.getLogEntries((RequestContext)ctx, (String)args[0], (Integer)args[1], timeConstraints);
observer.onResult(new ExecutionResult(result));
} catch (CougarException ce) {
observer.onResult(new ExecutionResult(ce));
} catch (TestingException ex) {
observer.onResult(new ExecutionResult((CougarApplicationException)ex));
};
}
});
executableMap.put(TestingServiceDefinition.getLogEntriesByDateRangeKey,
new Executable() {
@Override
public void execute(ExecutionContext ctx, OperationKey key,
Object[] args, ExecutionObserver observer,
ExecutionVenue executionVenue, TimeConstraints timeConstraints) {
try {
LogFileResponse result = service.getLogEntriesByDateRange((RequestContext)ctx, (String)args[0], (String)args[1], (String)args[2], timeConstraints);
observer.onResult(new ExecutionResult(result));
} catch (CougarException ce) {
observer.onResult(new ExecutionResult(ce));
} catch (TestingException ex) {
observer.onResult(new ExecutionResult((CougarApplicationException)ex));
};
}
});
}
public void setService(TestingService service) {
this.service = service;
}
@Override
public Executable resolveExecutable(OperationKey operationKey, ExecutionVenue ev) {
return executableMap.get(operationKey);
}
}