use of org.goobi.beans.Project in project goobi-workflow by intranda.
the class UserBean method AusProjektLoeschen.
private String AusProjektLoeschen(int projektID) {
List<Project> neu = new ArrayList<>();
for (Project p : this.myClass.getProjekte()) {
if (p.getId().intValue() != projektID) {
neu.add(p);
}
}
this.myClass.setProjekte(neu);
if (!myClass.getAllUserRoles().contains("Admin_All_Mail_Notifications")) {
UserManager.deleteEmailAssignmentForProject(myClass, projektID);
}
UserManager.deleteProjectAssignment(myClass, projektID);
updateProjectPaginator();
return "";
}
use of org.goobi.beans.Project in project goobi-workflow by intranda.
the class ProjectManager method convert.
/* +++++++++++++++++++++++++++++++++++++++++ Converter +++++++++++++++++++++++++++++++++++++++++++++++ */
public static Project convert(ResultSet rs) throws SQLException {
Project r = new Project();
r.setId(rs.getInt("ProjekteID"));
r.setTitel(rs.getString("Titel"));
r.setProjectIdentifier(rs.getString("project_identifier"));
r.setUseDmsImport(rs.getBoolean("useDmsImport"));
r.setDmsImportTimeOut(rs.getInt("dmsImportTimeOut"));
if (rs.wasNull()) {
r.setDmsImportTimeOut(null);
}
r.setDmsImportRootPath(rs.getString("dmsImportRootPath"));
r.setDmsImportImagesPath(rs.getString("dmsImportImagesPath"));
r.setDmsImportSuccessPath(rs.getString("dmsImportSuccessPath"));
r.setDmsImportErrorPath(rs.getString("dmsImportErrorPath"));
r.setDmsImportCreateProcessFolder(rs.getBoolean("dmsImportCreateProcessFolder"));
r.setFileFormatInternal(rs.getString("fileFormatInternal"));
r.setFileFormatDmsExport(rs.getString("fileFormatDmsExport"));
r.setMetsRightsOwner(rs.getString("metsRightsOwner"));
r.setMetsRightsOwnerLogo(rs.getString("metsRightsOwnerLogo"));
r.setMetsRightsOwnerSite(rs.getString("metsRightsOwnerSite"));
r.setMetsRightsOwnerMail(rs.getString("metsRightsOwnerMail"));
r.setMetsDigiprovReference(rs.getString("metsDigiprovReference"));
r.setMetsDigiprovPresentation(rs.getString("metsDigiprovPresentation"));
r.setMetsDigiprovReferenceAnchor(rs.getString("metsDigiprovReferenceAnchor"));
r.setMetsDigiprovPresentationAnchor(rs.getString("metsDigiprovPresentationAnchor"));
r.setMetsPointerPath(rs.getString("metsPointerPath"));
r.setMetsPointerPathAnchor(rs.getString("metsPointerPathAnchor"));
r.setMetsPurl(rs.getString("metsPurl"));
r.setMetsContentIDs(rs.getString("metsContentIDs"));
Timestamp startDate = rs.getTimestamp("startDate");
if (startDate != null) {
r.setStartDate(new Date(startDate.getTime()));
}
Timestamp endDate = rs.getTimestamp("endDate");
if (endDate != null) {
r.setEndDate(new Date(endDate.getTime()));
}
r.setNumberOfPages(rs.getInt("numberOfPages"));
r.setNumberOfVolumes(rs.getInt("numberOfVolumes"));
r.setProjectIsArchived(rs.getBoolean("projectIsArchived"));
r.setMetsRightsSponsor(rs.getString("metsRightsSponsor"));
r.setMetsRightsSponsorLogo(rs.getString("metsRightsSponsorLogo"));
r.setMetsRightsSponsorSiteURL(rs.getString("metsRightsSponsorSiteURL"));
r.setMetsRightsLicense(rs.getString("metsRightsLicense"));
int institutionId = rs.getInt("institution_id");
if (institutionId != 0) {
Institution institution = InstitutionManager.getInstitutionById(institutionId);
r.setInstitution(institution);
}
r.setMetsIIIFUrl(rs.getString("iiifUrl"));
r.setMetsSruUrl(rs.getString("sruUrl"));
return r;
}
use of org.goobi.beans.Project in project goobi-workflow by intranda.
the class ProjectMysqlHelper method getAllProjects.
public static List<Project> getAllProjects() throws SQLException {
Connection connection = null;
StringBuilder sql = new StringBuilder();
sql.append("SELECT * FROM projekte order by titel");
try {
connection = MySQLHelper.getInstance().getConnection();
if (log.isTraceEnabled()) {
log.trace(sql.toString());
}
List<Project> ret = new QueryRunner().query(connection, sql.toString(), ProjectManager.resultSetToProjectListHandler);
return ret;
} finally {
if (connection != null) {
MySQLHelper.closeConnection(connection);
}
}
}
use of org.goobi.beans.Project in project goobi-workflow by intranda.
the class ProjectMysqlHelper method getProjectByName.
static Project getProjectByName(String name) throws SQLException {
Connection connection = null;
StringBuilder sql = new StringBuilder();
sql.append("SELECT * FROM projekte WHERE Titel = ?");
try {
connection = MySQLHelper.getInstance().getConnection();
if (log.isTraceEnabled()) {
log.trace(sql.toString());
}
Project ret = new QueryRunner().query(connection, sql.toString(), ProjectManager.resultSetToProjectHandler, name);
return ret;
} finally {
if (connection != null) {
MySQLHelper.closeConnection(connection);
}
}
}
use of org.goobi.beans.Project in project goobi-workflow by intranda.
the class UserMysqlHelper method getEmailConfigurationForUser.
/**
* Get all tasks for each project where the user has been assigned to. Check for each task, if the user has configured to get emails.
*
* @param projects
* @param id
* @return
* @throws SQLException
*/
public static List<UserProjectConfiguration> getEmailConfigurationForUser(List<Project> projects, Integer id, boolean showAllItems) throws SQLException {
List<UserProjectConfiguration> answer = new ArrayList<>();
if (projects == null || projects.isEmpty() || !SendMail.getInstance().getConfig().isEnableMail()) {
return answer;
}
Connection connection = null;
try {
connection = MySQLHelper.getInstance().getConnection();
StringBuilder sql = new StringBuilder();
if (MySQLHelper.isJsonCapable()) {
// found mariadb
sql.append("SELECT ");
sql.append(" id, sub.titel AS stepName, open, inWork, done, error ");
sql.append("FROM ");
sql.append(" (SELECT DISTINCT ");
sql.append(" s.titel ");
sql.append(" FROM ");
sql.append(" schritte s ");
sql.append(" WHERE ");
sql.append(" s.ProzesseID IN (SELECT ");
sql.append(" ProzesseID ");
sql.append(" FROM ");
sql.append(" prozesse ");
sql.append(" WHERE ");
sql.append(" ProjekteID = ?) ");
if (!showAllItems) {
sql.append("INTERSECT ");
sql.append("SELECT DISTINCT ");
sql.append(" s.titel ");
sql.append(" FROM ");
sql.append(" schritte s ");
sql.append(" WHERE ");
sql.append(" s.SchritteId IN (SELECT ");
sql.append(" schritteID ");
sql.append(" FROM ");
sql.append(" schritteberechtigtegruppen ");
sql.append(" WHERE ");
sql.append(" BenutzerGruppenID IN (SELECT ");
sql.append(" b.BenutzerGruppenID ");
sql.append(" FROM ");
sql.append(" benutzergruppenmitgliedschaft bm ");
sql.append(" LEFT JOIN benutzergruppen b ON bm.BenutzerGruppenID = b.BenutzerGruppenID ");
sql.append(" WHERE ");
sql.append(" bm.BenutzerID = ?)) ");
}
sql.append(" ORDER BY titel) sub ");
sql.append(" LEFT JOIN ");
sql.append(" user_email_configuration uec ON sub.titel = uec.stepname ");
sql.append(" AND uec.projectid = ? ");
sql.append(" AND uec.userid = ? ");
} else {
// older sql version without INTERSECT command
if (showAllItems) {
sql.append("SELECT id, sub.titel AS stepName, open, inWork, done, error FROM (SELECT DISTINCT titel FROM schritte s1 WHERE ");
sql.append("EXISTS (SELECT NULL FROM prozesse WHERE ProjekteID = ? AND ProzesseID = s1.ProzesseID) ORDER BY titel) sub ");
sql.append("LEFT JOIN user_email_configuration uec ON sub.titel = uec.stepname AND uec.projectid = ? AND uec.userid = ? ");
} else {
sql.append("SELECT id, sub.titel AS stepName, open, inWork, done, error FROM (SELECT DISTINCT titel FROM schritte s1 WHERE ");
sql.append("EXISTS (SELECT NULL FROM prozesse WHERE ProjekteID = ? AND ProzesseID = s1.ProzesseID) ");
sql.append("AND EXISTS (SELECT NULL FROM schritteberechtigtegruppen WHERE ");
sql.append("s1.SchritteID = schritteberechtigtegruppen.schritteID AND schritteberechtigtegruppen.BenutzerGruppenID in ");
sql.append("(SELECT benutzergruppenmitgliedschaft.BenutzerGruppenID FROM benutzergruppenmitgliedschaft WHERE ");
sql.append("benutzergruppenmitgliedschaft.BenutzerID = ?)) ORDER BY titel) sub LEFT JOIN user_email_configuration uec ON ");
sql.append("sub.titel = uec.stepname AND uec.projectid = ? AND uec.userid = ?");
}
}
for (Project project : projects) {
UserProjectConfiguration upc = new UserProjectConfiguration();
upc.setProjectName(project.getTitel());
upc.setProjectId(project.getId());
List<StepConfiguration> stepNames = null;
if (showAllItems) {
stepNames = new QueryRunner().query(connection, sql.toString(), new BeanListHandler<>(StepConfiguration.class), project.getId(), project.getId(), id);
} else {
stepNames = new QueryRunner().query(connection, sql.toString(), new BeanListHandler<>(StepConfiguration.class), project.getId(), id, project.getId(), id);
}
upc.setStepList(stepNames);
if (stepNames != null && !stepNames.isEmpty()) {
answer.add(upc);
}
}
return answer;
} finally {
if (connection != null) {
MySQLHelper.closeConnection(connection);
}
}
}
Aggregations