OLINGO-573: removing the type warnings during the build
This commit is contained in:
parent
05cbf674fb
commit
fbdf9aadc8
|
@ -103,6 +103,7 @@ public class ServiceDispatcher extends RequestURLHierarchyVisitor {
|
|||
// http://localhost/EntitySet(key)
|
||||
if (this.idOption != null) {
|
||||
try {
|
||||
this.request.setODataRequest(odRequest);
|
||||
this.request = this.request.parseLink(new URI(this.idOption));
|
||||
} catch (URISyntaxException e) {
|
||||
throw new ODataHandlerException("Invalid $id value",
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.apache.olingo.server.core;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -139,6 +140,7 @@ public abstract class ServiceRequest {
|
|||
return this.request.getMethod() == HttpMethod.POST;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getSerializerOptions(Class<T> serilizerOptions, ContextURL contextUrl,
|
||||
boolean references) throws ContentNegotiatorException {
|
||||
final ODataFormat format = ODataFormat.fromContentType(getResponseContentType());
|
||||
|
@ -240,13 +242,17 @@ public abstract class ServiceRequest {
|
|||
return null;
|
||||
}
|
||||
|
||||
public DataRequest parseLink(URI uri) throws UriParserException {
|
||||
public DataRequest parseLink(URI uri) throws UriParserException, URISyntaxException {
|
||||
String path = "/";
|
||||
URI servicePath = new URI(getODataRequest().getRawBaseUri());
|
||||
path = servicePath.getPath();
|
||||
|
||||
String rawPath = uri.getPath();
|
||||
int e = rawPath.indexOf("/", 1);
|
||||
int e = rawPath.indexOf(path);
|
||||
if (-1 == e) {
|
||||
rawPath = uri.getPath();
|
||||
} else {
|
||||
rawPath = rawPath.substring(e);
|
||||
rawPath = rawPath.substring(e+path.length());
|
||||
}
|
||||
|
||||
UriInfo uriInfo = new Parser().parseUri(rawPath, uri.getQuery(), null,
|
||||
|
|
|
@ -85,6 +85,7 @@ public class ActionRequest extends OperationRequest {
|
|||
return (isPOST());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getSerializerOptions(Class<T> serilizerOptions, ContextURL contextUrl, boolean references)
|
||||
throws ContentNegotiatorException {
|
||||
|
|
|
@ -242,6 +242,7 @@ public class DataRequest extends ServiceRequest {
|
|||
this.type.execute(handler, response);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getSerializerOptions(Class<T> serilizerOptions, ContextURL contextUrl, boolean references)
|
||||
throws ContentNegotiatorException {
|
||||
|
|
|
@ -80,6 +80,7 @@ public class FunctionRequest extends OperationRequest {
|
|||
return isGET();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getSerializerOptions(Class<T> serilizerOptions, ContextURL contextUrl, boolean references)
|
||||
throws ContentNegotiatorException {
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.apache.olingo.server.api.OData;
|
|||
import org.apache.olingo.server.api.ServiceMetadata;
|
||||
import org.apache.olingo.server.api.serializer.RepresentationType;
|
||||
import org.apache.olingo.server.api.serializer.SerializerException;
|
||||
import org.apache.olingo.server.api.uri.UriHelper;
|
||||
import org.apache.olingo.server.core.ContentNegotiator;
|
||||
import org.apache.olingo.server.core.ContentNegotiatorException;
|
||||
import org.apache.olingo.server.core.ServiceRequest;
|
||||
|
@ -73,7 +72,7 @@ public abstract class OperationRequest extends ServiceRequest {
|
|||
return null;
|
||||
}
|
||||
|
||||
final UriHelper helper = odata.createUriHelper();
|
||||
//final UriHelper helper = odata.createUriHelper();
|
||||
|
||||
if (isReturnTypePrimitive() || isReturnTypeComplex()) {
|
||||
// Part 1 {10.14, 10.14} since the function return properties does not
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.olingo.server.api.ServiceMetadata;
|
|||
public class NoContentResponse extends ServiceResponse {
|
||||
|
||||
public NoContentResponse(ServiceMetadata metadata, ODataResponse response) {
|
||||
super(metadata, response, Collections.EMPTY_MAP);
|
||||
super(metadata, response, Collections.<String,String>emptyMap());
|
||||
}
|
||||
|
||||
// 200
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.apache.olingo.server.core.responses;
|
|||
import org.apache.olingo.server.api.ODataApplicationException;
|
||||
import org.apache.olingo.server.api.ODataTranslatedException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ServiceResponseVisior {
|
||||
|
||||
public void visit(CountResponse response) throws ODataTranslatedException,
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.apache.olingo.server.api.ServiceMetadata;
|
|||
public class StreamResponse extends ServiceResponse {
|
||||
|
||||
public StreamResponse(ServiceMetadata metadata, ODataResponse response) {
|
||||
super(metadata, response, Collections.EMPTY_MAP);
|
||||
super(metadata, response, Collections.<String,String>emptyMap());
|
||||
}
|
||||
|
||||
public void writeStreamResponse(InputStream streamContent, ContentType contentType) {
|
||||
|
|
|
@ -404,6 +404,7 @@ public class ServiceDispatcherTest {
|
|||
final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
|
||||
helpTest(handler, "trippin/People('russelwhyte')/Friends/$ref", "POST", payload,
|
||||
new TestResult() {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void validate() throws Exception {
|
||||
ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
|
||||
|
|
|
@ -57,22 +57,18 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
|
||||
public class TripPinDataModel {
|
||||
private final ServiceMetadata metadata;
|
||||
private HashMap<String, EntityCollection> entitySetMap;
|
||||
private Map<Integer, Map> tripLinks;
|
||||
private Map<String, Map> peopleLinks;
|
||||
private Map<Integer, Map> flightLinks;
|
||||
private HashMap<String, EntityCollection> entitySetMap = new HashMap<String, EntityCollection>();
|
||||
private Map<Integer, Map<String,Object>> tripLinks = new HashMap<Integer, Map<String,Object>>();
|
||||
private Map<String, Map<String,Object>> peopleLinks = new HashMap<String, Map<String,Object>>();
|
||||
private Map<Integer, Map<String, Object>> flightLinks = new HashMap<Integer, Map<String, Object>>();
|
||||
|
||||
public TripPinDataModel(ServiceMetadata metadata) throws Exception {
|
||||
this.metadata = metadata;
|
||||
loadData();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void loadData() throws Exception {
|
||||
this.entitySetMap = new HashMap<String, EntityCollection>();
|
||||
this.tripLinks = new HashMap<Integer, Map>();
|
||||
this.peopleLinks = new HashMap<String, Map>();
|
||||
this.flightLinks = new HashMap<Integer, Map>();
|
||||
|
||||
EdmEntityContainer ec = metadata.getEdm().getEntityContainer(null);
|
||||
for (EdmEntitySet edmEntitySet : ec.getEntitySets()) {
|
||||
String entitySetName = edmEntitySet.getName();
|
||||
|
@ -95,24 +91,24 @@ public class TripPinDataModel {
|
|||
this.entitySetMap.put("Event", loadEnities("Event", type));
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Map tripLinks = mapper.readValue(new FileInputStream(new File(
|
||||
Map<String, List<Object>> tripLinks = mapper.readValue(new FileInputStream(new File(
|
||||
"src/test/resources/trip-links.json")), Map.class);
|
||||
for (Object link : (ArrayList) tripLinks.get("value")) {
|
||||
Map map = (Map) link;
|
||||
for (Object link : tripLinks.get("value")) {
|
||||
Map<String, Object> map = (Map<String, Object>) link;
|
||||
this.tripLinks.put((Integer) map.get("TripId"), map);
|
||||
}
|
||||
|
||||
Map peopleLinks = mapper.readValue(new FileInputStream(new File(
|
||||
Map<String, List<Object>> peopleLinks = mapper.readValue(new FileInputStream(new File(
|
||||
"src/test/resources/people-links.json")), Map.class);
|
||||
for (Object link : (ArrayList) peopleLinks.get("value")) {
|
||||
Map map = (Map) link;
|
||||
for (Object link : peopleLinks.get("value")) {
|
||||
Map<String, Object> map = (Map<String, Object>) link;
|
||||
this.peopleLinks.put((String) map.get("UserName"), map);
|
||||
}
|
||||
|
||||
Map flightLinks = mapper.readValue(new FileInputStream(new File(
|
||||
Map<String, List<Object>> flightLinks = mapper.readValue(new FileInputStream(new File(
|
||||
"src/test/resources/flight-links.json")), Map.class);
|
||||
for (Object link : (ArrayList) flightLinks.get("value")) {
|
||||
Map map = (Map) link;
|
||||
for (Object link : flightLinks.get("value")) {
|
||||
Map<String, Object> map = (Map<String, Object>) link;
|
||||
this.flightLinks.put((Integer) map.get("PlanItemId"), map);
|
||||
}
|
||||
}
|
||||
|
@ -245,6 +241,7 @@ public class TripPinDataModel {
|
|||
return search.get(0);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private EntityCollection getFriends(String userName) {
|
||||
Map<String, Object> map = this.peopleLinks.get(userName);
|
||||
if (map == null) {
|
||||
|
@ -270,6 +267,7 @@ public class TripPinDataModel {
|
|||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private EntityCollection getTrips(String userName) {
|
||||
Map<String, Object> map = this.peopleLinks.get(userName);
|
||||
if (map == null) {
|
||||
|
@ -320,8 +318,9 @@ public class TripPinDataModel {
|
|||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private EntityCollection getEvents(int tripId, EntityCollection result) {
|
||||
Map<Integer, Object> map = this.tripLinks.get(tripId);
|
||||
Map<String, Object> map = this.tripLinks.get(tripId);
|
||||
if (map == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -344,8 +343,9 @@ public class TripPinDataModel {
|
|||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private EntityCollection getFlights(int tripId, EntityCollection result) {
|
||||
Map<Integer, Object> map = this.tripLinks.get(tripId);
|
||||
Map<String, Object> map = this.tripLinks.get(tripId);
|
||||
if (map == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -368,8 +368,9 @@ public class TripPinDataModel {
|
|||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private EntityCollection getTripPhotos(int tripId) {
|
||||
Map<Integer, Object> map = this.tripLinks.get(tripId);
|
||||
Map<String, Object> map = this.tripLinks.get(tripId);
|
||||
if (map == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -451,15 +452,16 @@ public class TripPinDataModel {
|
|||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addNavigationLink(String navigation, Entity parentEntity, Entity childEntity) {
|
||||
|
||||
EdmEntityType type = this.metadata.getEdm().getEntityType(
|
||||
new FullQualifiedName(parentEntity.getType()));
|
||||
String key = type.getKeyPredicateNames().get(0);
|
||||
if (type.getName().equals("Person") && navigation.equals("Friends")) {
|
||||
Map map = this.peopleLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.peopleLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map == null) {
|
||||
map = new HashMap();
|
||||
map = new HashMap<String, Object>();
|
||||
this.peopleLinks.put((String) parentEntity.getProperty(key).getValue(), map);
|
||||
}
|
||||
|
||||
|
@ -471,9 +473,9 @@ public class TripPinDataModel {
|
|||
friends.add((String) childEntity.getProperty(key).getValue());
|
||||
setLink(parentEntity, navigation, childEntity);
|
||||
} else if (type.getName().equals("Person") && navigation.equals("Trips")) {
|
||||
Map map = this.peopleLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.peopleLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map == null) {
|
||||
map = new HashMap();
|
||||
map = new HashMap<String, Object>();
|
||||
this.peopleLinks.put((String) parentEntity.getProperty(key).getValue(), map);
|
||||
}
|
||||
|
||||
|
@ -485,17 +487,17 @@ public class TripPinDataModel {
|
|||
trips.add((Integer) childEntity.getProperty(key).getValue());
|
||||
setLink(parentEntity, navigation, childEntity);
|
||||
} else if (type.getName().equals("Person") && navigation.equals("Photo")) {
|
||||
Map map = this.peopleLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.peopleLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map == null) {
|
||||
map = new HashMap();
|
||||
map = new HashMap<String, Object>();
|
||||
this.peopleLinks.put((String) parentEntity.getProperty(key).getValue(), map);
|
||||
}
|
||||
map.put("Photo", childEntity.getProperty(key).getValue());
|
||||
setLink(parentEntity, navigation, childEntity);
|
||||
} else if (type.getName().equals("Trip") && navigation.equals("PlanItems")) {
|
||||
Map map = this.tripLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.tripLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map == null) {
|
||||
map = new HashMap();
|
||||
map = new HashMap<String, Object>();
|
||||
this.tripLinks.put((Integer) parentEntity.getProperty(key).getValue(), map);
|
||||
}
|
||||
if (childEntity.getType().equals("Flight")) {
|
||||
|
@ -515,9 +517,9 @@ public class TripPinDataModel {
|
|||
}
|
||||
setLink(parentEntity, navigation, childEntity);
|
||||
} else if (type.getName().equals("Trip") && navigation.equals("Photo")) {
|
||||
Map map = this.tripLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.tripLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map == null) {
|
||||
map = new HashMap();
|
||||
map = new HashMap<String, Object>();
|
||||
this.tripLinks.put((Integer) parentEntity.getProperty(key).getValue(), map);
|
||||
}
|
||||
ArrayList<Integer> photos = (ArrayList<Integer>) map.get("Photos");
|
||||
|
@ -528,25 +530,25 @@ public class TripPinDataModel {
|
|||
photos.add((Integer) childEntity.getProperty(key).getValue());
|
||||
setLink(parentEntity, navigation, childEntity);
|
||||
} else if (type.getName().equals("Flight") && navigation.equals("From")) {
|
||||
Map map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map == null) {
|
||||
map = new HashMap();
|
||||
map = new HashMap<String, Object>();
|
||||
this.flightLinks.put((Integer) parentEntity.getProperty(key).getValue(), map);
|
||||
}
|
||||
map.put("From", childEntity.getProperty(key).getValue());
|
||||
setLink(parentEntity, navigation, childEntity);
|
||||
} else if (type.getName().equals("Flight") && navigation.equals("To")) {
|
||||
Map map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map == null) {
|
||||
map = new HashMap();
|
||||
map = new HashMap<String, Object>();
|
||||
this.flightLinks.put((Integer) parentEntity.getProperty(key).getValue(), map);
|
||||
}
|
||||
map.put("To", childEntity.getProperty(key).getValue());
|
||||
setLink(parentEntity, navigation, childEntity);
|
||||
} else if (type.getName().equals("Flight") && navigation.equals("Airline")) {
|
||||
Map map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map == null) {
|
||||
map = new HashMap();
|
||||
map = new HashMap<String, Object>();
|
||||
this.flightLinks.put((Integer) parentEntity.getProperty(key).getValue(), map);
|
||||
}
|
||||
map.put("Airline", childEntity.getProperty(key).getValue());
|
||||
|
@ -576,25 +578,25 @@ public class TripPinDataModel {
|
|||
String updateKey = updateType.getKeyPredicateNames().get(0);
|
||||
|
||||
if (type.getName().equals("Person") && navigationProperty.equals("Photo")) {
|
||||
Map map = this.peopleLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.peopleLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map != null) {
|
||||
map.put("Photo", ((Long) updateEntity.getProperty(updateKey).getValue()).intValue());
|
||||
updated = true;
|
||||
}
|
||||
} else if (type.getName().equals("Flight") && navigationProperty.equals("From")) {
|
||||
Map map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map != null) {
|
||||
map.put("From", updateEntity.getProperty(updateKey).getValue());
|
||||
updated = true;
|
||||
}
|
||||
} else if (type.getName().equals("Flight") && navigationProperty.equals("To")) {
|
||||
Map map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map != null) {
|
||||
map.put("To", updateEntity.getProperty(updateKey).getValue());
|
||||
updated = true;
|
||||
}
|
||||
} else if (type.getName().equals("Flight") && navigationProperty.equals("Airline")) {
|
||||
Map map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map != null) {
|
||||
map.put("Airline", updateEntity.getProperty(updateKey).getValue());
|
||||
updated = true;
|
||||
|
@ -717,6 +719,7 @@ public class TripPinDataModel {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean removeNavigationLink(String navigationProperty, Entity parentEntity,
|
||||
Entity deleteEntity) {
|
||||
boolean removed = false;
|
||||
|
@ -725,7 +728,7 @@ public class TripPinDataModel {
|
|||
String key = type.getKeyPredicateNames().get(0);
|
||||
|
||||
if (type.getName().equals("Person") && navigationProperty.equals("Friends")) {
|
||||
Map map = this.peopleLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.peopleLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map != null) {
|
||||
ArrayList<String> friends = (ArrayList<String>) map.get("Friends");
|
||||
if (friends != null) {
|
||||
|
@ -734,7 +737,7 @@ public class TripPinDataModel {
|
|||
}
|
||||
}
|
||||
} else if (type.getName().equals("Person") && navigationProperty.equals("Trips")) {
|
||||
Map map = this.peopleLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.peopleLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map != null) {
|
||||
ArrayList<Integer> trips = (ArrayList<Integer>) map.get("Trips");
|
||||
if (trips != null) {
|
||||
|
@ -743,13 +746,13 @@ public class TripPinDataModel {
|
|||
}
|
||||
}
|
||||
} else if (type.getName().equals("Person") && navigationProperty.equals("Photo")) {
|
||||
Map map = this.peopleLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.peopleLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map != null) {
|
||||
map.remove("Photo");
|
||||
removed = true;
|
||||
}
|
||||
} else if (type.getName().equals("Trip") && navigationProperty.equals("PlanItems")) {
|
||||
Map map = this.tripLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.tripLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map != null) {
|
||||
if (deleteEntity.getType().equals("Flight")) {
|
||||
ArrayList<Integer> flights = (ArrayList<Integer>) map.get("Flights");
|
||||
|
@ -766,7 +769,7 @@ public class TripPinDataModel {
|
|||
}
|
||||
}
|
||||
} else if (type.getName().equals("Trip") && navigationProperty.equals("Photo")) {
|
||||
Map map = this.tripLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.tripLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map != null) {
|
||||
ArrayList<Integer> photos = (ArrayList<Integer>) map.get("Photos");
|
||||
if (photos != null) {
|
||||
|
@ -775,19 +778,19 @@ public class TripPinDataModel {
|
|||
}
|
||||
}
|
||||
} else if (type.getName().equals("Flight") && navigationProperty.equals("From")) {
|
||||
Map map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map != null) {
|
||||
map.remove("From");
|
||||
removed = true;
|
||||
}
|
||||
} else if (type.getName().equals("Flight") && navigationProperty.equals("To")) {
|
||||
Map map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map != null) {
|
||||
map.remove("To");
|
||||
removed = true;
|
||||
}
|
||||
} else if (type.getName().equals("Flight") && navigationProperty.equals("Airline")) {
|
||||
Map map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
Map<String, Object> map = this.flightLinks.get(parentEntity.getProperty(key).getValue());
|
||||
if (map != null) {
|
||||
map.remove("Airline");
|
||||
removed = true;
|
||||
|
|
|
@ -439,11 +439,15 @@ public class TripPinHandler implements ServiceHandler {
|
|||
|
||||
final EntityDetails details = process(request);
|
||||
|
||||
for (URI reference : references) {
|
||||
DataRequest bindingRequest = request.parseLink(reference);
|
||||
Entity linkEntity = this.dataModel.getEntity(bindingRequest.getEntitySet().getName(),
|
||||
bindingRequest.getKeyPredicates());
|
||||
this.dataModel.addNavigationLink(details.navigationProperty, details.entity, linkEntity);
|
||||
try {
|
||||
for (URI reference : references) {
|
||||
DataRequest bindingRequest = request.parseLink(reference);
|
||||
Entity linkEntity = this.dataModel.getEntity(bindingRequest.getEntitySet().getName(),
|
||||
bindingRequest.getKeyPredicates());
|
||||
this.dataModel.addNavigationLink(details.navigationProperty, details.entity, linkEntity);
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
throw new ODataApplicationException(e.getMessage(), 500, Locale.getDefault(), e);
|
||||
}
|
||||
response.writeNoContent();
|
||||
}
|
||||
|
@ -452,14 +456,18 @@ public class TripPinHandler implements ServiceHandler {
|
|||
public void updateReference(DataRequest request, String entityETag, URI updateId,
|
||||
NoContentResponse response) throws ODataTranslatedException, ODataApplicationException {
|
||||
// this single valued navigation.
|
||||
final EntityDetails details = process(request);
|
||||
DataRequest updateRequest = request.parseLink(updateId);
|
||||
Entity updateEntity = this.dataModel.getEntity(updateRequest.getEntitySet().getName(),
|
||||
updateRequest.getKeyPredicates());
|
||||
boolean updated = false;
|
||||
if (updateEntity != null) {
|
||||
updated = this.dataModel.updateNavigationLink(details.navigationProperty,
|
||||
details.parentEntity, updateEntity);
|
||||
try {
|
||||
final EntityDetails details = process(request);
|
||||
DataRequest updateRequest = request.parseLink(updateId);
|
||||
Entity updateEntity = this.dataModel.getEntity(updateRequest.getEntitySet().getName(),
|
||||
updateRequest.getKeyPredicates());
|
||||
if (updateEntity != null) {
|
||||
updated = this.dataModel.updateNavigationLink(details.navigationProperty,
|
||||
details.parentEntity, updateEntity);
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
throw new ODataApplicationException(e.getMessage(), 500, Locale.getDefault(), e);
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
|
@ -474,13 +482,17 @@ public class TripPinHandler implements ServiceHandler {
|
|||
NoContentResponse response) throws ODataTranslatedException, ODataApplicationException {
|
||||
boolean removed = false;
|
||||
if (deleteId != null) {
|
||||
final EntityDetails details = process(request);
|
||||
DataRequest deleteRequest = request.parseLink(deleteId);
|
||||
Entity deleteEntity = this.dataModel.getEntity(deleteRequest.getEntitySet().getName(),
|
||||
deleteRequest.getKeyPredicates());
|
||||
if (deleteEntity != null) {
|
||||
removed = this.dataModel.removeNavigationLink(details.navigationProperty, details.entity,
|
||||
deleteEntity);
|
||||
try {
|
||||
final EntityDetails details = process(request);
|
||||
DataRequest deleteRequest = request.parseLink(deleteId);
|
||||
Entity deleteEntity = this.dataModel.getEntity(deleteRequest.getEntitySet().getName(),
|
||||
deleteRequest.getKeyPredicates());
|
||||
if (deleteEntity != null) {
|
||||
removed = this.dataModel.removeNavigationLink(details.navigationProperty, details.entity,
|
||||
deleteEntity);
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
throw new ODataApplicationException(e.getMessage(), 500, Locale.getDefault(), e);
|
||||
}
|
||||
} else {
|
||||
// this single valued navigation.
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
package org.apache.olingo.server.example;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -46,7 +47,6 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.olingo.commons.api.edm.provider.EdmProvider;
|
|||
import org.apache.olingo.server.api.OData;
|
||||
import org.apache.olingo.server.api.ODataHttpHandler;
|
||||
import org.apache.olingo.server.api.ServiceMetadata;
|
||||
import org.apache.olingo.server.api.edmx.EdmxReference;
|
||||
import org.apache.olingo.server.core.MetadataParser;
|
||||
import org.apache.olingo.server.core.OData4Impl;
|
||||
|
||||
|
@ -57,7 +58,7 @@ public class TripPinServlet extends HttpServlet {
|
|||
throw new IOException(e);
|
||||
}
|
||||
|
||||
ServiceMetadata metadata = odata.createServiceMetadata(edmProvider, Collections.EMPTY_LIST);
|
||||
ServiceMetadata metadata = odata.createServiceMetadata(edmProvider, Collections.<EdmxReference>emptyList());
|
||||
|
||||
ODataHttpHandler handler = odata.createHandler(metadata);
|
||||
|
||||
|
|
Loading…
Reference in New Issue