2021-11-02 14:51:10 +01:00
|
|
|
package org.gcube.portlets.user.moving;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
2021-11-03 11:09:23 +01:00
|
|
|
import java.sql.Connection;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.ResultSet;
|
2021-11-02 14:51:10 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2021-11-02 18:00:49 +01:00
|
|
|
import javax.portlet.ActionRequest;
|
|
|
|
import javax.portlet.ActionResponse;
|
2021-11-02 14:51:10 +01:00
|
|
|
import javax.portlet.PortletException;
|
|
|
|
import javax.portlet.RenderRequest;
|
|
|
|
import javax.portlet.RenderResponse;
|
|
|
|
|
2021-11-03 11:09:23 +01:00
|
|
|
import org.gcube.common.portal.PortalContext;
|
|
|
|
|
2021-11-02 14:51:10 +01:00
|
|
|
|
|
|
|
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
|
|
|
import com.liferay.util.bridges.mvc.MVCPortlet;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Portlet implementation class ThematicGateways
|
|
|
|
*/
|
|
|
|
public class CompileForm extends MVCPortlet {
|
|
|
|
private static com.liferay.portal.kernel.log.Log _log = LogFactoryUtil.getLog(CompileForm.class);
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException {
|
2021-11-03 11:09:23 +01:00
|
|
|
Connection conn = null;
|
|
|
|
try {
|
|
|
|
conn = DatabaseConnection.getInstance("/"+PortalContext.getConfiguration().getInfrastructureName()).getConnection();
|
|
|
|
} catch (Exception e) {
|
|
|
|
_log.error("Something wrong with Database connection, name: "+DatabaseConnection.DB_SERVICE_ENDPOINT_NAME);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if (conn != null) {
|
|
|
|
List<String> organisation_types = getOrganisationTypes(conn);
|
|
|
|
List<String> main_motivations = getMainMotivations(conn);
|
|
|
|
List<String> areas_of_expertise = getAreasOfExpertise(conn);
|
|
|
|
List<String> degrees_of_participation = getDgreesOfParticipation(conn);
|
|
|
|
renderRequest.setAttribute("organisation_types", organisation_types);
|
|
|
|
renderRequest.setAttribute("main_motivations", main_motivations);
|
|
|
|
renderRequest.setAttribute("areas_of_expertise", areas_of_expertise);
|
|
|
|
renderRequest.setAttribute("degrees_of_participation", degrees_of_participation);
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
_log.error("Something wrong with Database queries while getting combo types", e);
|
|
|
|
}
|
2021-11-02 14:51:10 +01:00
|
|
|
super.render(renderRequest, renderResponse);
|
|
|
|
}
|
2021-11-03 11:09:23 +01:00
|
|
|
|
2021-11-02 18:00:49 +01:00
|
|
|
public void addEntry(ActionRequest request, ActionResponse response) {
|
|
|
|
System.out.println("bao");
|
|
|
|
}
|
2021-11-02 14:51:10 +01:00
|
|
|
|
2021-11-03 11:09:23 +01:00
|
|
|
private static List<String> getOrganisationTypes(Connection conn) throws Exception {
|
|
|
|
_log.debug("getting organisation_types ");
|
|
|
|
List<String> toReturn = new ArrayList<>();
|
|
|
|
String selectSQL = "SELECT * FROM organisation_types";
|
|
|
|
PreparedStatement preparedStatement = conn.prepareStatement(selectSQL);
|
|
|
|
ResultSet rs = preparedStatement.executeQuery();
|
|
|
|
while (rs.next()) {
|
|
|
|
String toAdd = rs.getString("combo_value");
|
|
|
|
_log.debug("Adding organisation_types" + toAdd);
|
|
|
|
toReturn.add(toAdd);
|
|
|
|
}
|
|
|
|
return toReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static List<String> getMainMotivations(Connection conn) throws Exception {
|
|
|
|
_log.debug("getting main_motivations ");
|
|
|
|
List<String> toReturn = new ArrayList<>();
|
|
|
|
String selectSQL = "SELECT * FROM main_motivations";
|
|
|
|
PreparedStatement preparedStatement = conn.prepareStatement(selectSQL);
|
|
|
|
ResultSet rs = preparedStatement.executeQuery();
|
|
|
|
while (rs.next()) {
|
|
|
|
String toAdd = rs.getString("combo_value");
|
|
|
|
_log.debug("Adding main_motivations" + toAdd);
|
|
|
|
toReturn.add(toAdd);
|
|
|
|
}
|
|
|
|
return toReturn;
|
|
|
|
}
|
2021-11-02 14:51:10 +01:00
|
|
|
|
2021-11-03 11:09:23 +01:00
|
|
|
private static List<String> getAreasOfExpertise(Connection conn) throws Exception {
|
|
|
|
_log.debug("getting areas_of_expertise ");
|
|
|
|
List<String> toReturn = new ArrayList<>();
|
|
|
|
String selectSQL = "SELECT * FROM areas_of_expertise";
|
|
|
|
PreparedStatement preparedStatement = conn.prepareStatement(selectSQL);
|
|
|
|
ResultSet rs = preparedStatement.executeQuery();
|
|
|
|
while (rs.next()) {
|
|
|
|
String toAdd = rs.getString("combo_value");
|
|
|
|
_log.debug("Adding areas_of_expertise" + toAdd);
|
|
|
|
toReturn.add(toAdd);
|
|
|
|
}
|
|
|
|
return toReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static List<String> getDgreesOfParticipation(Connection conn) throws Exception {
|
|
|
|
_log.debug("getting degrees_of_participation ");
|
|
|
|
List<String> toReturn = new ArrayList<>();
|
|
|
|
String selectSQL = "SELECT * FROM degrees_of_participation";
|
|
|
|
PreparedStatement preparedStatement = conn.prepareStatement(selectSQL);
|
|
|
|
ResultSet rs = preparedStatement.executeQuery();
|
|
|
|
while (rs.next()) {
|
|
|
|
String toAdd = rs.getString("combo_value");
|
|
|
|
_log.debug("Adding degrees_of_participation" + toAdd);
|
|
|
|
toReturn.add(toAdd);
|
|
|
|
}
|
|
|
|
return toReturn;
|
|
|
|
}
|
2021-11-02 14:51:10 +01:00
|
|
|
}
|