Skip to content

Commit df57e0b

Browse files
author
DoxasticFox
committed
Petra's changes
1 parent 25d7b2e commit df57e0b

17 files changed

+857
-742
lines changed

logic/custom-search.bsh

+18-15
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ void populateSite() {
3333
all.add("");
3434
all.add("{All}");
3535

36-
List menuEntries = new ArrayList(getMenuEntries("AreaCode"));
36+
String attrName = getAttributeName("Context/General/AreaCode");
37+
List menuEntries = getMenuEntries(attrName);
38+
menuEntries = new ArrayList(menuEntries);
3739
menuEntries.add(0, all);
3840

3941
populateDropDown("Control/Search/Select_AreaCode", menuEntries, false);
@@ -51,36 +53,37 @@ void search(){
5153
String type = getFieldValue(refEntityTypes);
5254
String term = getFieldValue(refSearchTerm);
5355
String user = getFieldValue(refSelectUser);
54-
String area = getFieldValue(refSelectSite);
56+
String area = getFieldValue(refSelectSite, true);
5557
if (isNull(user)) return;
5658
String searchQuery = "SELECT uuid, response " +
5759
" FROM latestNonDeletedArchEntFormattedIdentifiers " +
5860
" WHERE uuid in (SELECT uuid " +
5961
" FROM latestNonDeletedArchEntIdentifiers " +
60-
" WHERE measure LIKE '{term}%' " +
61-
" AND ( aenttypename LIKE '{type}' OR '' = '{type}' ) " +
62-
" AND ( userid = {user} OR -1 = {user}) " +
62+
" WHERE measure LIKE {term}||'%' " +
63+
" AND ( aenttypename LIKE {type} OR '' = {type} ) " +
64+
" AND ( userid = {user} OR '-1' = {user}) " +
6365
" ) " +
6466
" AND ( " +
65-
" ('{area}' = '') OR" +
67+
" ({area} = '') OR" +
6668
" uuid IN (" +
6769
" SELECT uuid" +
6870
" FROM latestnondeletedaentvalue" +
6971
" JOIN attributekey USING (attributeid)" +
70-
" WHERE attributename = 'AreaCode'" +
71-
" AND vocabid = '{area}'" +
72+
" JOIN vocabulary USING (vocabid)" +
73+
" WHERE attributename LIKE '% AreaCode'" +
74+
" AND vocabname = {area}" +
7275
" )" +
7376
" )" +
7477
" ORDER BY response " +
7578
" LIMIT ? " +
7679
"OFFSET ? ";
77-
searchQuery = replaceFirst(searchQuery, "{term}", term);
78-
searchQuery = replaceFirst(searchQuery, "{type}", type);
79-
searchQuery = replaceFirst(searchQuery, "{type}", type);
80-
searchQuery = replaceFirst(searchQuery, "{user}", user);
81-
searchQuery = replaceFirst(searchQuery, "{user}", user);
82-
searchQuery = replaceFirst(searchQuery, "{area}", area);
83-
searchQuery = replaceFirst(searchQuery, "{area}", area);
80+
searchQuery = dbReplaceFirst(searchQuery, "{term}", term);
81+
searchQuery = dbReplaceFirst(searchQuery, "{type}", type);
82+
searchQuery = dbReplaceFirst(searchQuery, "{type}", type);
83+
searchQuery = dbReplaceFirst(searchQuery, "{user}", user);
84+
searchQuery = dbReplaceFirst(searchQuery, "{user}", user);
85+
searchQuery = dbReplaceFirst(searchQuery, "{area}", area);
86+
searchQuery = dbReplaceFirst(searchQuery, "{area}", area);
8487

8588
populateCursorList(refEntityList, searchQuery, 25);
8689
refreshTabgroupCSS(tabgroup);

logic/field-inheritance.bsh

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/***************************** FIELD INHERITANCE ******************************/
2+
/* TODO: Write these using the `i` attribute in the module.xml file. */
3+
/******************************************************************************/
24
String moduleYear = new java.text.SimpleDateFormat("yy").format(new Date());
35
String moduleSiteCode = "BK" + moduleYear;
46

@@ -13,10 +15,10 @@ inheritContextFields() {
1315
"Context/General/Excavators"
1416
);
1517

16-
copyFieldValue(
17-
"User/User_List/AreaCode",
18-
"Context/General/AreaCode"
19-
);
18+
//copyFieldValue(
19+
//"User/User_List/AreaCode",
20+
//"Context/General/AreaCode"
21+
//);
2022

2123
copyFieldValue(
2224
"User/User_List/Device_Code",

logic/local-settings-access.bsh

-44
This file was deleted.

logic/relationships-context-group-to-context.bsh

+29-14
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,21 @@ CGsearchRelationship() {
105105
String refAreaCode = "Context_Group_Relationship/Relationships/AreaCode";
106106
String refContextId = "Context_Group_Relationship/Relationships/Context_ID";
107107

108-
String areaCode = getFieldValue(refAreaCode);
108+
String areaCode = getFieldValue(refAreaCode, true);
109109
String contextId = getFieldValue(refContextId);
110110
String parentRole = "includes";
111111
String unrelatedQ = "";
112112
String relatedQ = "";
113113

114+
String refContextAreaCode = "Context/General/AreaCode";
115+
String refLegacyAreaCode = "Legacy/Legacy/AreaCode";
116+
String refContextContextId = "Context/General/Context_Context_ID";
117+
String refLegacyContextId = "Legacy/Legacy/Legacy_Context_ID";
118+
String contextAreaCode = getAttributeName(refContextAreaCode);
119+
String legacyAreaCode = getAttributeName(refLegacyAreaCode);
120+
String contextContextId = getAttributeName(refContextContextId);
121+
String legacyContextId = getAttributeName(refLegacyContextId);
122+
114123
if (isNull(areaCode)) {
115124
msgHead = "Trench required";
116125
msgBody = "Searching requires that the Trench field is filled in.";
@@ -128,27 +137,33 @@ CGsearchRelationship() {
128137
unrelatedQ += " FROM latestNonDeletedArchEntFormattedIdentifiers";
129138
unrelatedQ += " WHERE uuid IN (";
130139
unrelatedQ += " SELECT uuid";
131-
unrelatedQ += " FROM latestnondeletedaentvalue JOIN attributekey USING (attributeid)";
132-
unrelatedQ += " WHERE attributename = 'AreaCode'";
133-
unrelatedQ += " AND vocabid = '{AreaCode}'";
140+
unrelatedQ += " FROM latestnondeletedaentvalue";
141+
unrelatedQ += " JOIN attributekey USING (attributeid)";
142+
unrelatedQ += " JOIN vocabulary USING (vocabid)";
143+
unrelatedQ += " WHERE attributename IN ({Context_AreaCode}, {Legacy_AreaCode})";
144+
unrelatedQ += " AND vocabname = {AreaCode}";
134145
unrelatedQ += " AND uuid IN (";
135146
unrelatedQ += " SELECT uuid";
136147
unrelatedQ += " FROM latestnondeletedaentvalue JOIN attributekey USING (attributeid) ";
137-
unrelatedQ += " WHERE attributename IN ('Context Context ID', 'Legacy Context ID')";
138-
unrelatedQ += " AND measure = '{Context_ID}')";
148+
unrelatedQ += " WHERE attributename IN ({Context_Context_ID}, {Legacy_Context_ID})";
149+
unrelatedQ += " AND measure = {Context_ID})";
139150
unrelatedQ += " AND uuid NOT IN (";
140151
unrelatedQ += " SELECT childuuid";
141152
unrelatedQ += " FROM parentchild";
142-
unrelatedQ += " WHERE parentuuid = '{parentUuid}'";
143-
unrelatedQ += " AND parentparticipatesverb = '{parentRole}')";
144-
unrelatedQ += " AND uuid != '{parentUuid}')";
153+
unrelatedQ += " WHERE parentuuid = {parentUuid}";
154+
unrelatedQ += " AND parentparticipatesverb = {parentRole})";
155+
unrelatedQ += " AND uuid != {parentUuid})";
145156
unrelatedQ += " ORDER BY response";
146157
unrelatedQ += " LIMIT ? OFFSET ?";
147-
unrelatedQ = replaceFirst(unrelatedQ, "{AreaCode}", areaCode );
148-
unrelatedQ = replaceFirst(unrelatedQ, "{Context_ID}", contextId );
149-
unrelatedQ = replaceFirst(unrelatedQ, "{parentUuid}", parentUuid);
150-
unrelatedQ = replaceFirst(unrelatedQ, "{parentUuid}", parentUuid);
151-
unrelatedQ = replaceFirst(unrelatedQ, "{parentRole}", parentRole);
158+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{Context_AreaCode}", contextAreaCode);
159+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{Legacy_AreaCode}", legacyAreaCode);
160+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{AreaCode}", areaCode );
161+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{Context_Context_ID}", contextContextId);
162+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{Legacy_Context_ID}", legacyContextId);
163+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{Context_ID}", contextId );
164+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{parentUuid}", parentUuid);
165+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{parentUuid}", parentUuid);
166+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{parentRole}", parentRole);
152167

153168
relatedQ += getCGChildQuery(parentUuid);
154169

logic/relationships-context-to-context.bsh

+29-14
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,21 @@ searchRelationship() {
145145
String refAreaCode = "Relationship/Relationships/AreaCode";
146146
String refContextId = "Relationship/Relationships/Context_ID";
147147

148-
String areaCode = getFieldValue(refAreaCode);
148+
String areaCode = getFieldValue(refAreaCode, true);
149149
String contextId = getFieldValue(refContextId);
150150
String parentRole = getSelectedRelationshipComponent(refRelType, "parent");
151151
String unrelatedQ = "";
152152
String relatedQ = "";
153153

154+
String refContextAreaCode = "Context/General/AreaCode";
155+
String refLegacyAreaCode = "Legacy/Legacy/AreaCode";
156+
String refContextContextId = "Context/General/Context_Context_ID";
157+
String refLegacyContextId = "Legacy/Legacy/Legacy_Context_ID";
158+
String contextAreaCode = getAttributeName(refContextAreaCode);
159+
String legacyAreaCode = getAttributeName(refLegacyAreaCode);
160+
String contextContextId = getAttributeName(refContextContextId);
161+
String legacyContextId = getAttributeName(refLegacyContextId);
162+
154163
if (isNull(areaCode)) {
155164
msgHead = "Trench required";
156165
msgBody = "Searching requires that the Trench field is filled in.";
@@ -168,28 +177,34 @@ searchRelationship() {
168177
unrelatedQ += " FROM latestNonDeletedArchEntFormattedIdentifiers";
169178
unrelatedQ += " WHERE uuid IN (";
170179
unrelatedQ += " SELECT uuid";
171-
unrelatedQ += " FROM latestnondeletedaentvalue JOIN attributekey USING (attributeid)";
172-
unrelatedQ += " WHERE attributename = 'AreaCode'";
173-
unrelatedQ += " AND vocabid = '{AreaCode}'";
180+
unrelatedQ += " FROM latestnondeletedaentvalue";
181+
unrelatedQ += " JOIN attributekey USING (attributeid)";
182+
unrelatedQ += " JOIN vocabulary USING (vocabid)";
183+
unrelatedQ += " WHERE attributename IN ({Context_AreaCode}, {Legacy_AreaCode})";
184+
unrelatedQ += " AND vocabname = {AreaCode}";
174185
unrelatedQ += " AND uuid IN (";
175186
unrelatedQ += " SELECT uuid";
176187
unrelatedQ += " FROM latestnondeletedaentvalue JOIN attributekey USING (attributeid) ";
177-
unrelatedQ += " WHERE attributename IN ('Context Context ID', 'Legacy Context ID')";
178-
unrelatedQ += " AND measure = '{Context_ID}')";
188+
unrelatedQ += " WHERE attributename IN ({Context_Context_ID}, {Legacy_Context_ID})";
189+
unrelatedQ += " AND measure = {Context_ID})";
179190
unrelatedQ += " AND uuid NOT IN (";
180191
unrelatedQ += " SELECT childuuid";
181192
unrelatedQ += " FROM parentchild";
182-
unrelatedQ += " WHERE parentuuid = '{parentUuid}'";
183-
unrelatedQ += " AND parentparticipatesverb = '{parentRole}')";
184-
unrelatedQ += " AND uuid != '{parentUuid}')";
193+
unrelatedQ += " WHERE parentuuid = {parentUuid}";
194+
unrelatedQ += " AND parentparticipatesverb = {parentRole})";
195+
unrelatedQ += " AND uuid != {parentUuid})";
185196
unrelatedQ += " AND aenttypename IN ('Context', 'Legacy')";
186197
unrelatedQ += " ORDER BY response";
187198
unrelatedQ += " LIMIT ? OFFSET ?";
188-
unrelatedQ = replaceFirst(unrelatedQ, "{AreaCode}", areaCode );
189-
unrelatedQ = replaceFirst(unrelatedQ, "{Context_ID}", contextId );
190-
unrelatedQ = replaceFirst(unrelatedQ, "{parentUuid}", parentUuid);
191-
unrelatedQ = replaceFirst(unrelatedQ, "{parentUuid}", parentUuid);
192-
unrelatedQ = replaceFirst(unrelatedQ, "{parentRole}", parentRole);
199+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{Context_AreaCode}", contextAreaCode);
200+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{Legacy_AreaCode}", legacyAreaCode);
201+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{AreaCode}", areaCode );
202+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{Context_Context_ID}", contextContextId);
203+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{Legacy_Context_ID}", legacyContextId);
204+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{Context_ID}", contextId );
205+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{parentUuid}", parentUuid);
206+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{parentUuid}", parentUuid);
207+
unrelatedQ = dbReplaceFirst(unrelatedQ, "{parentRole}", parentRole);
193208

194209
relatedQ += getRelatedChildQuery(parentUuid);
195210

logic/top-matter.bsh

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
/* Disabling sync by default fixes a bug where the database is locked when it
44
* should not be.
55
*/
6-
setFileSyncEnabled(true);
7-
setSyncEnabled(true);
6+
setFileSyncEnabled(false);
7+
setSyncEnabled(false);

logic/vocab-population.bsh

-12
This file was deleted.

0 commit comments

Comments
 (0)