Skip to content

Commit

Permalink
Merge pull request #330 from phoenixctms/file_departments
Browse files Browse the repository at this point in the history
File departments
  • Loading branch information
rkrenn authored Oct 22, 2024
2 parents 3cb223c + abb48b2 commit 9c9ac38
Show file tree
Hide file tree
Showing 72 changed files with 11,830 additions and 9,867 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public final class JSFVOConverterIDs {
public final static String TIMELINE_EVENT_CONVERTER_ID = "ctsms.TimelineEvent";
public final static String PROBAND_GROUP_CONVERTER_ID = "ctsms.ProbandGroup";
public final static String VISIT_CONVERTER_ID = "ctsms.Visit";
public final static String DEPARTMENT_CONVERTER_ID = "ctsms.Department";
public final static Collection<String> CONVERTER_IDS = new HashSet<String>();
static {
CONVERTER_IDS.add(ALPHA_ID_CONVERTER_ID);
Expand All @@ -33,6 +34,7 @@ public final class JSFVOConverterIDs {
CONVERTER_IDS.add(TIMELINE_EVENT_CONVERTER_ID);
CONVERTER_IDS.add(PROBAND_GROUP_CONVERTER_ID);
CONVERTER_IDS.add(VISIT_CONVERTER_ID);
CONVERTER_IDS.add(DEPARTMENT_CONVERTER_ID);
}

private JSFVOConverterIDs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,13 +592,17 @@ public interface ServiceExceptionCodes {
public final static String FILE_TRIAL_ONLY_ALLOWED = "file_trial_only_allowed";
public final static String FILE_PROBAND_ONLY_ALLOWED = "file_proband_only_allowed";
public final static String FILE_MASS_MAIL_ONLY_ALLOWED = "file_mass_mail_only_allowed";
public final static String FILE_DEPARTMENT_ID_IS_NULL = "file_department_id_is_null";
public final static String FILE_DUPLICATE_DEPARTMENT = "file_duplicate_department";
public final static String INVALID_LOGICAL_PATH = "invalid_logical_path";
public final static String INVALID_HYPERLINK_ID = "invalid_hyperlink_id";
public final static String HYPERLINK_INVENTORY_ONLY_ALLOWED = "hyperlink_inventory_only_allowed";
public final static String HYPERLINK_STAFF_ONLY_ALLOWED = "hyperlink_staff_only_allowed";
public final static String HYPERLINK_COURSE_ONLY_ALLOWED = "hyperlink_course_only_allowed";
public final static String HYPERLINK_TRIAL_ONLY_ALLOWED = "hyperlink_trial_only_allowed";
public final static String INVALID_URL = "invalid_url";
public final static String HYPERLINK_DEPARTMENT_ID_IS_NULL = "hyperlink_department_id_is_null";
public final static String HYPERLINK_DUPLICATE_DEPARTMENT = "hyperlink_duplicate_department";
public final static String INVALID_PHONE_NUMBER = "invalid_phone_number";
public final static String INVALID_EMAIL_ADDRESS = "invalid_email_address";
public final static String INVALID_DATE_FORMAT = "invalid_date_format";
Expand Down
30 changes: 30 additions & 0 deletions core/db/schema-create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2119,6 +2119,16 @@
VISITS_FK BIGINT not null
);

create table file_department (
FILES_FK BIGINT not null,
DEPARTMENTS_FK BIGINT not null
);

create table hyperlink_department (
HYPERLINKS_FK BIGINT not null,
DEPARTMENTS_FK BIGINT not null
);

create table input_field_value_selection (
INPUT_FIELD_VALUES_FK BIGINT not null,
SELECTION_VALUES_FK BIGINT not null
Expand Down Expand Up @@ -3710,6 +3720,26 @@
foreign key (ECRFS_FK)
references ecrf;

alter table file_department
add constraint DEPARTMENT_FILES_FKC
foreign key (FILES_FK)
references FILE;

alter table file_department
add constraint FILE_DEPARTMENTS_FKC
foreign key (DEPARTMENTS_FK)
references DEPARTMENT;

alter table hyperlink_department
add constraint DEPARTMENT_HYPERLINKS_FKC
foreign key (HYPERLINKS_FK)
references HYPERLINK;

alter table hyperlink_department
add constraint HYPERLINK_DEPARTMENTS_FKC
foreign key (DEPARTMENTS_FK)
references DEPARTMENT;

alter table input_field_value_selection
add constraint INPUT_FIELD_VALUE_SELECTION_VALUES_FKC
foreign key (SELECTION_VALUES_FK)
Expand Down
16 changes: 16 additions & 0 deletions core/db/schema-drop.sql
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,18 @@
alter table ecrf_visit
drop constraint VISIT_ECRFS_FKC;

alter table file_department
drop constraint DEPARTMENT_FILES_FKC;

alter table file_department
drop constraint FILE_DEPARTMENTS_FKC;

alter table hyperlink_department
drop constraint DEPARTMENT_HYPERLINKS_FKC;

alter table hyperlink_department
drop constraint HYPERLINK_DEPARTMENTS_FKC;

alter table input_field_value_selection
drop constraint INPUT_FIELD_VALUE_SELECTION_VALUES_FKC;

Expand Down Expand Up @@ -1269,6 +1281,10 @@

drop table ecrf_visit cascade;

drop table file_department cascade;

drop table hyperlink_department cascade;

drop table input_field_value_selection cascade;

drop table mass_mail_status_transition cascade;
Expand Down
2 changes: 1 addition & 1 deletion core/db/schema-set-version.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ begin
end
$$ language plpgsql;

select set_database_version('010801060');
select set_database_version('010801070');
33 changes: 33 additions & 0 deletions core/db/schema-up-master.sql
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,39 @@ if get_database_version() < '010801060' then

end if;

if get_database_version() < '010801070' then

create table file_department (
FILES_FK BIGINT not null,
DEPARTMENTS_FK BIGINT not null
);

create table hyperlink_department (
HYPERLINKS_FK BIGINT not null,
DEPARTMENTS_FK BIGINT not null
);

alter table file_department
add constraint DEPARTMENT_FILES_FKC
foreign key (FILES_FK)
references FILE;

alter table file_department
add constraint FILE_DEPARTMENTS_FKC
foreign key (DEPARTMENTS_FK)
references DEPARTMENT;

alter table hyperlink_department
add constraint DEPARTMENT_HYPERLINKS_FKC
foreign key (HYPERLINKS_FK)
references HYPERLINK;

alter table hyperlink_department
add constraint HYPERLINK_DEPARTMENTS_FKC
foreign key (DEPARTMENTS_FK)
references DEPARTMENT;

end if;

end
$$;
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.phoenixctms.ctsms.compare;

import java.util.Comparator;

import org.phoenixctms.ctsms.vo.DepartmentVO;

public class DepartmentVOComparator extends AlphanumComparatorBase implements Comparator<DepartmentVO> {

@Override
public int compare(DepartmentVO a, DepartmentVO b) {
if (a != null && b != null) {
int nameComparison = comp(a.getName(), b.getName());
if (nameComparison != 0) {
return nameComparison;
} else {
if (a.getId() > b.getId()) {
return 1;
} else if (a.getId() < b.getId()) {
return -1;
} else {
return 0;
}
}
} else if (a == null && b != null) {
return -1;
} else if (a != null && b == null) {
return 1;
} else {
return 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ protected Collection<Course> handleFindUpcoming(
// )
// ));
DetachedCriteria subQuery = DetachedCriteria.forClass(CourseParticipationStatusEntryImpl.class, "courseParticipationStatusEntry"); // IMPL!!!!
subQuery.setProjection(Projections.rowCount());
subQuery.setProjection(Projections.id());
subQuery.add(Restrictions.eqProperty("course.id", "course0.id"));
subQuery.add(Restrictions.eq("staff.id", staffId.longValue()));
courseCriteria.add(Restrictions.or(
Expand All @@ -403,7 +403,7 @@ protected Collection<Course> handleFindUpcoming(
Restrictions.ge("participationDeadline", now))),
Restrictions.and(
Restrictions.and(Restrictions.eq("selfRegistration", false), Restrictions.ge("stop", new Date(now.getTime()))),
Subqueries.lt(0l, subQuery))));
Subqueries.exists(subQuery))));
CriteriaUtil.applyPSFVO(criteriaMap, psf); // unique participant staff per course
return courseCriteria.list();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,15 @@ protected Collection<Object[]> handleFindByListEntryActiveSorted(Long probandLis
subQuery.add(Restrictions.eqProperty("ecrf.id", ecrfCriteria.getAlias() + ".id"));
subQuery.add(Restrictions.or(Restrictions.and(Restrictions.isNull("ecrfStatusEntry.visit.id"), Restrictions.isNull(visitCriteria.getAlias() + ".id")),
Restrictions.eqProperty("ecrfStatusEntry.visit.id", visitCriteria.getAlias() + ".id")));
subQuery.setProjection(Projections.rowCount());
ecrfCriteria.add(Restrictions.or(conjunction, Subqueries.lt(0l, subQuery)));
subQuery.setProjection(Projections.id());
ecrfCriteria.add(Restrictions.or(conjunction, Subqueries.exists(subQuery)));
// DetachedCriteria subQuery = DetachedCriteria.forClass(ECRFFieldImpl.class, "ecrfField"); // IMPL!!!!
// subQuery.createCriteria("fieldValues", "ecrfFieldValues", CriteriaSpecification.INNER_JOIN).add(Restrictions.eq("listEntry.id", probandListEntryId.longValue()));
// subQuery.add(Restrictions.eqProperty("ecrf.id", ecrfCriteria.getAlias() + ".id"));
// subQuery.add(Restrictions.or(Restrictions.and(Restrictions.isNull("ecrfFieldValues.visit.id"), Restrictions.isNull(visitCriteria.getAlias() + ".id")),
// Restrictions.eqProperty("ecrfFieldValues.visit.id", visitCriteria.getAlias() + ".id")));
// subQuery.setProjection(Projections.rowCount());
// ecrfCriteria.add(Restrictions.or(conjunction, Subqueries.lt(0l, subQuery)));
// ecrfCriteria.add(Restrictions.or(conjunction, Subqueries.exists( subQuery)));
if (sort) {
if (psf == null) {
psf = new PSFVO();
Expand Down
Loading

0 comments on commit 9c9ac38

Please sign in to comment.