Skip to content

Commit

Permalink
fix exposing odata for view (#3972)
Browse files Browse the repository at this point in the history
* fix exposing odata for view

Signed-off-by: Iliyan Velichkov <[email protected]>

* fix, handle the case where keys are missing (views)

Signed-off-by: Iliyan Velichkov <[email protected]>

---------

Signed-off-by: Iliyan Velichkov <[email protected]>
  • Loading branch information
iliyan-velichkov authored May 29, 2024
1 parent 93bdaaa commit 4268fce
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
import org.apache.olingo.odata2.core.commons.ContentType;
import org.apache.olingo.odata2.core.uri.KeyPredicateImpl;
import org.apache.olingo.odata2.core.uri.UriInfoImpl;
import org.eclipse.dirigible.engine.odata2.sql.api.*;
import org.eclipse.dirigible.engine.odata2.sql.api.OData2EventHandler;
import org.eclipse.dirigible.engine.odata2.sql.api.SQLProcessor;
import org.eclipse.dirigible.engine.odata2.sql.api.SQLStatement;
import org.eclipse.dirigible.engine.odata2.sql.api.SQLStatementParam;
import org.eclipse.dirigible.engine.odata2.sql.builder.*;
import org.eclipse.dirigible.engine.odata2.sql.builder.SQLUtils;
import org.eclipse.dirigible.engine.odata2.sql.utils.OData2Utils;
import org.eclipse.dirigible.engine.odata2.sql.utils.SingleConnectionDataSource;
import org.slf4j.Logger;
Expand All @@ -51,7 +53,10 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.sql.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;

import static org.eclipse.dirigible.engine.odata2.sql.builder.EdmUtils.getProperties;
Expand Down Expand Up @@ -320,7 +325,7 @@ public ODataResponse readEntitySet(final GetEntitySetUriInfo uriInfo, final Stri
ResultSetReader.ResultSetEntity currentTargetEntity =
resultSetReader.getResultSetEntity(query, targetEntityType, properties, resultSet, hasGeneratedId);
logger.info("Current entity set object is {}", currentTargetEntity);
if (!currentAccumulator.isAccumulatorFor(currentTargetEntity)) {
if (!currentAccumulator.isAccumulatorFor(currentTargetEntity) || currentTargetEntity.keys.isEmpty()) {
currentAccumulator = new ResultSetReader.ExpandAccumulator(currentTargetEntity);
entitiesFeed.add(currentAccumulator);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
*/
package org.eclipse.dirigible.engine.odata2.sql.processor;

import org.apache.olingo.odata2.api.edm.*;
import org.apache.olingo.odata2.api.edm.EdmEntityType;
import org.apache.olingo.odata2.api.edm.EdmException;
import org.apache.olingo.odata2.api.edm.EdmProperty;
import org.apache.olingo.odata2.api.edm.EdmStructuralType;
import org.apache.olingo.odata2.api.exception.ODataException;
import org.apache.olingo.odata2.api.uri.NavigationPropertySegment;
import org.eclipse.dirigible.engine.odata2.sql.api.SQLProcessor;
Expand Down Expand Up @@ -305,6 +308,7 @@ public Map<String, Object> renderForExpand(ExpandAccumulator input) {
}
}


/**
* The Class ResultSetEntity.
*/
Expand Down Expand Up @@ -387,6 +391,11 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(keys);
}

@Override
public String toString() {
return "ResultSetEntity{" + "data=" + data + ", keys=" + keys + ", entityType=" + entityType + '}';
}
}

}

0 comments on commit 4268fce

Please sign in to comment.