in odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/processor/ScenarioDataSource.java [84:137]
public Object readData(final EdmEntitySet entitySet, final Map<String, Object> keys)
throws ODataNotImplementedException, ODataNotFoundException, EdmException {
if (ENTITYSET_1_1.equals(entitySet.getName())) {
for (final Employee employee : dataContainer.getEmployees()) {
if (employee.getId().equals(keys.get("EmployeeId"))) {
return employee;
}
}
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
} else if (ENTITYSET_1_2.equals(entitySet.getName())) {
for (final Team team : dataContainer.getTeams()) {
if (team.getId().equals(keys.get("Id"))) {
return team;
}
}
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
} else if (ENTITYSET_1_3.equals(entitySet.getName())) {
for (final Room room : dataContainer.getRooms()) {
if (room.getId().equals(keys.get("Id"))) {
return room;
}
}
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
} else if (ENTITYSET_1_4.equals(entitySet.getName())) {
for (final Manager manager : dataContainer.getManagers()) {
if (manager.getId().equals(keys.get("EmployeeId"))) {
return manager;
}
}
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
} else if (ENTITYSET_1_5.equals(entitySet.getName())) {
for (final Building building : dataContainer.getBuildings()) {
if (building.getId().equals(keys.get("Id"))) {
return building;
}
}
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
} else if (ENTITYSET_2_1.equals(entitySet.getName())) {
for (final Photo photo : dataContainer.getPhotos()) {
if (photo.getId() == (Integer) keys.get("Id")
&& photo.getType().equals(keys.get("Type"))) {
return photo;
}
}
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
throw new ODataNotImplementedException();
}