use of org.wso2.ei.dashboard.core.rest.model.ArtifactDetails in project product-mi-tooling by wso2.
the class JDBCDatabaseManager method getArtifactDetails.
private List<ArtifactDetails> getArtifactDetails(String getServicesQuery, String artifactName, String groupId, List<String> nodeList) {
try (Connection con = getConnection();
PreparedStatement statement = con.prepareStatement(getServicesQuery)) {
statement.setString(1, artifactName);
statement.setString(2, groupId);
for (int i = 0, j = 3; i < nodeList.size(); i++, j++) {
statement.setString(j, nodeList.get(i));
}
ResultSet resultSet = statement.executeQuery();
List<ArtifactDetails> artifactDetailsList = new ArrayList<>();
while (resultSet.next()) {
ArtifactDetails artifactDetails = new ArtifactDetails();
String nodeId = resultSet.getString("NODE_ID");
String details = resultSet.getString("DETAILS");
artifactDetails.setNodeId(nodeId);
artifactDetails.setDetails(details);
artifactDetailsList.add(artifactDetails);
}
return artifactDetailsList;
} catch (SQLException e) {
throw new DashboardServerException("Error occurred while retrieving next row.", e);
}
}
use of org.wso2.ei.dashboard.core.rest.model.ArtifactDetails in project product-mi-tooling by wso2.
the class JDBCDatabaseManager method fetchArtifacts.
@Override
public Artifacts fetchArtifacts(String artifactType, String groupId, List<String> nodeList) {
Artifacts artifacts = new Artifacts();
String nodeSearch = "";
String nodeSearchTmp = nodeSearch;
nodeList.forEach(node -> nodeSearchTmp.concat("NODE_ID=? OR "));
nodeSearch = nodeSearchTmp;
for (int i = 0; i < nodeList.size(); i++) {
nodeSearch = nodeSearch.concat("NODE_ID=? OR ");
}
if (!nodeSearch.equals("")) {
nodeSearch = nodeSearch.substring(0, nodeSearch.length() - 4);
}
String tableName = getTableName(artifactType);
String getDistinctNamesQuery = "SELECT DISTINCT NAME FROM " + tableName + " WHERE GROUP_ID=? " + "AND (" + nodeSearch + ");";
String getDetailsQuery = "SELECT NODE_ID, DETAILS FROM " + tableName + " WHERE NAME=? AND GROUP_ID=? AND " + "(" + nodeSearch + ");";
try (Connection con = getConnection();
PreparedStatement statement = con.prepareStatement(getDistinctNamesQuery)) {
statement.setString(1, groupId);
for (int i = 0, j = 2; i < nodeList.size(); i++, j++) {
statement.setString(j, nodeList.get(i));
}
ResultSet resultSet = statement.executeQuery();
while (resultSet.next()) {
ArtifactsInner artifactsInner = new ArtifactsInner();
String artifactName = resultSet.getString("NAME");
artifactsInner.setName(artifactName);
List<ArtifactDetails> artifactDetails = getArtifactDetails(getDetailsQuery, artifactName, groupId, nodeList);
artifactsInner.setNodes(artifactDetails);
artifacts.add(artifactsInner);
}
return artifacts;
} catch (SQLException e) {
throw new DashboardServerException("Error occurred fetching " + artifactType, e);
}
}
use of org.wso2.ei.dashboard.core.rest.model.ArtifactDetails in project product-mi-tooling by wso2.
the class JDBCDatabaseManager method insertArtifact.
@Override
public boolean insertArtifact(String groupId, String nodeId, String artifactType, String artifactName, String artifactDetails) {
String query = "INSERT INTO " + getTableName(artifactType) + " VALUES (?,?,?,?);";
try (Connection con = getConnection();
PreparedStatement statement = con.prepareStatement(query)) {
statement.setString(1, groupId);
statement.setString(2, nodeId);
statement.setString(3, artifactName);
statement.setString(4, artifactDetails);
return statement.executeUpdate() > 0;
} catch (SQLException e) {
throw new DashboardServerException("Error occurred while inserting " + artifactName + " information.", e);
}
}
Aggregations