-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d60dd8
commit 9fe8d0a
Showing
6 changed files
with
138 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 75 additions & 75 deletions
150
src/main/java/io/rtdi/bigdata/s4hanaconnector/rest/SourceTableService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,76 @@ | ||
package io.rtdi.bigdata.s4hanaconnector.rest; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.annotation.security.RolesAllowed; | ||
import jakarta.servlet.ServletContext; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.Configuration; | ||
import jakarta.ws.rs.core.Context; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
import io.rtdi.bigdata.connector.connectorframework.WebAppController; | ||
import io.rtdi.bigdata.connector.connectorframework.controller.ConnectionController; | ||
import io.rtdi.bigdata.connector.connectorframework.controller.ConnectorController; | ||
import io.rtdi.bigdata.connector.connectorframework.rest.JAXBErrorResponseBuilder; | ||
import io.rtdi.bigdata.connector.connectorframework.rest.JAXBSuccessResponseBuilder; | ||
import io.rtdi.bigdata.connector.connectorframework.servlet.ServletSecurityConstants; | ||
import io.rtdi.bigdata.s4hanaconnector.S4HanaTableMapping; | ||
import io.rtdi.bigdata.s4hanaconnector.S4HanaBrowse; | ||
import io.rtdi.bigdata.s4hanaconnector.S4HanaBrowse.TableImport; | ||
import io.rtdi.bigdata.s4hanaconnector.S4HanaConnectionProperties; | ||
|
||
@Path("/") | ||
public class SourceTableService { | ||
@Context | ||
private Configuration configuration; | ||
|
||
@Context | ||
private ServletContext servletContext; | ||
|
||
public SourceTableService() { | ||
} | ||
|
||
@GET | ||
@Path("/connections/{connectionname}/sourcetables") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@RolesAllowed({ServletSecurityConstants.ROLE_VIEW}) | ||
public Response getFiles(@PathParam("connectionname") String connectionname, @PathParam("name") String name) { | ||
try { | ||
ConnectorController connector = WebAppController.getConnectorOrFail(servletContext); | ||
ConnectionController connection = connector.getConnectionOrFail(connectionname); | ||
S4HanaBrowse browser = (S4HanaBrowse) connection.getBrowser(); | ||
return Response.ok(browser.getHanaTables()).build(); | ||
} catch (Exception e) { | ||
return JAXBErrorResponseBuilder.getJAXBResponse(e); | ||
} | ||
} | ||
|
||
@POST | ||
@Path("/connections/{connectionname}/sourcetables") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@RolesAllowed({ServletSecurityConstants.ROLE_VIEW}) | ||
public Response getFiles(@PathParam("connectionname") String connectionname, List<TableImport> data) { | ||
try { | ||
ConnectorController connector = WebAppController.getConnectorOrFail(servletContext); | ||
ConnectionController connection = connector.getConnectionOrFail(connectionname); | ||
S4HanaConnectionProperties props = (S4HanaConnectionProperties) connection.getConnectionProperties(); | ||
String dbuser = props.getUsername(); | ||
String dbschema = props.getSourceSchema(); | ||
S4HanaBrowse browser = (S4HanaBrowse) connection.getBrowser(); | ||
for (TableImport t : data) { | ||
S4HanaTableMapping entity = new S4HanaTableMapping(t.getSchemaname(), dbuser, dbschema, t.getTablename(), "L1", browser.getConnection()); | ||
entity.write(browser.getBusinessObjectDirectory()); | ||
} | ||
return JAXBSuccessResponseBuilder.getJAXBResponse("Saved " + data.size() + " table schemas"); | ||
} catch (Exception e) { | ||
return JAXBErrorResponseBuilder.getJAXBResponse(e); | ||
} | ||
} | ||
|
||
package io.rtdi.bigdata.s4hanaconnector.rest; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.annotation.security.RolesAllowed; | ||
import jakarta.servlet.ServletContext; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.Configuration; | ||
import jakarta.ws.rs.core.Context; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
import io.rtdi.bigdata.connector.connectorframework.WebAppController; | ||
import io.rtdi.bigdata.connector.connectorframework.controller.ConnectionController; | ||
import io.rtdi.bigdata.connector.connectorframework.controller.ConnectorController; | ||
import io.rtdi.bigdata.connector.connectorframework.rest.JAXBErrorResponseBuilder; | ||
import io.rtdi.bigdata.connector.connectorframework.rest.JAXBSuccessResponseBuilder; | ||
import io.rtdi.bigdata.connector.connectorframework.servlet.ServletSecurityConstants; | ||
import io.rtdi.bigdata.s4hanaconnector.S4HanaTableMapping; | ||
import io.rtdi.bigdata.s4hanaconnector.S4HanaBrowse; | ||
import io.rtdi.bigdata.s4hanaconnector.S4HanaBrowse.TableImport; | ||
import io.rtdi.bigdata.s4hanaconnector.S4HanaConnectionProperties; | ||
|
||
@Path("/") | ||
public class SourceTableService { | ||
@Context | ||
private Configuration configuration; | ||
|
||
@Context | ||
private ServletContext servletContext; | ||
|
||
public SourceTableService() { | ||
} | ||
|
||
@GET | ||
@Path("/connections/{connectionname}/sourcetables") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@RolesAllowed({ServletSecurityConstants.ROLE_VIEW}) | ||
public Response getFiles(@PathParam("connectionname") String connectionname, @PathParam("name") String name) { | ||
try { | ||
ConnectorController connector = WebAppController.getConnectorOrFail(servletContext); | ||
ConnectionController connection = connector.getConnectionOrFail(connectionname); | ||
S4HanaBrowse browser = (S4HanaBrowse) connection.getBrowser(); | ||
return Response.ok(browser.getHanaTables()).build(); | ||
} catch (Exception e) { | ||
return JAXBErrorResponseBuilder.getJAXBResponse(e); | ||
} | ||
} | ||
|
||
@POST | ||
@Path("/connections/{connectionname}/sourcetables") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@RolesAllowed({ServletSecurityConstants.ROLE_VIEW}) | ||
public Response getFiles(@PathParam("connectionname") String connectionname, List<TableImport> data) { | ||
try { | ||
ConnectorController connector = WebAppController.getConnectorOrFail(servletContext); | ||
ConnectionController connection = connector.getConnectionOrFail(connectionname); | ||
S4HanaConnectionProperties props = (S4HanaConnectionProperties) connection.getConnectionProperties(); | ||
String dbuser = props.getUsername(); | ||
String dbschema = props.getSourceSchema(); | ||
S4HanaBrowse browser = (S4HanaBrowse) connection.getBrowser(); | ||
for (TableImport t : data) { | ||
S4HanaTableMapping entity = new S4HanaTableMapping(t.getSchemaname(), dbuser, dbschema, t.getTablename(), "L1", t.getInitialloadwhere(), browser.getConnection()); | ||
entity.write(browser.getBusinessObjectDirectory()); | ||
} | ||
return JAXBSuccessResponseBuilder.getJAXBResponse("Saved " + data.size() + " table schemas"); | ||
} catch (Exception e) { | ||
return JAXBErrorResponseBuilder.getJAXBResponse(e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
|
||
<t:Table | ||
id="SourceTables" | ||
rows="{source>/}" | ||
visibleRowCountMode="Auto" | ||
selectionMode="None" | ||
enableBusyIndicator="true" | ||
enableSelectAll="false" | ||
ariaLabelledBy="title"> | ||
<t:columns> | ||
<t:Column width="50px"> | ||
<t:template> | ||
<CheckBox selected="{source>imported}" /> | ||
</t:template> | ||
</t:Column> | ||
<t:Column filterProperty="tablename" > | ||
<Label text="Table name (Click to Filter)"/> | ||
<t:template> | ||
<Text text="{source>tablename}" wrapping="false" renderWhitespace="false" /> | ||
</t:template> | ||
</t:Column> | ||
<t:Column > | ||
<Label text="Schema name"/> | ||
<t:template> | ||
<Input value="{source>schemaname}" /> | ||
</t:template> | ||
</t:Column> | ||
</t:columns> | ||
</t:Table> | ||
|
||
<t:Table | ||
id="SourceTables" | ||
rows="{source>/}" | ||
visibleRowCountMode="Auto" | ||
selectionMode="None" | ||
enableBusyIndicator="true" | ||
enableSelectAll="false" | ||
ariaLabelledBy="title"> | ||
<t:columns> | ||
<t:Column width="50px"> | ||
<t:template> | ||
<CheckBox selected="{source>imported}" /> | ||
</t:template> | ||
</t:Column> | ||
<t:Column filterProperty="tablename" > | ||
<Label text="Table name (Click to Filter)"/> | ||
<t:template> | ||
<Text text="{source>tablename}" wrapping="false" renderWhitespace="false" /> | ||
</t:template> | ||
</t:Column> | ||
<t:Column > | ||
<Label text="Schema name"/> | ||
<t:template> | ||
<Input value="{source>schemaname}" /> | ||
</t:template> | ||
</t:Column> | ||
<t:Column > | ||
<Label text="Initial Load where clause"/> | ||
<t:template> | ||
<Input value="{source>initialloadwhere}" /> | ||
</t:template> | ||
</t:Column> | ||
</t:columns> | ||
</t:Table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters