Skip to content

Commit ec74618

Browse files
committed
Updated the version. Fixed an issue where delete custom object fields prevented an object using them from being deleted.
1 parent 4207743 commit ec74618

File tree

5 files changed

+123
-41
lines changed

5 files changed

+123
-41
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<project default="run" basedir=".">
66

77
<property name="projectName" value="QuollWriter" />
8-
<property name="currVersion" value="2.6.13" />
8+
<property name="currVersion" value="2.6.14" />
99
<property name="thesaurusVersion" value="1.0" />
1010
<property name="buildDir" value="./build" />
1111
<property name="imgsDir" value="./imgs" />

data/default-ui-language-strings.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
":nativename" : "English",
44
":version" : 1,
55
":id" : ":English",
6-
":qwversion" : "2.6.13",
6+
":qwversion" : "2.6.14",
77
":created" : 0,
88
":email" : "gary@quollwriter.com",
99
":sections" :
@@ -5863,6 +5863,17 @@
58635863
"text" : "When using full screen mode, the normal ${objectnames.singular.project} window will be hidden."
58645864
}
58655865
}
5866+
},
5867+
"2.6.14" :
5868+
{
5869+
"items" :
5870+
{
5871+
"bugs" :
5872+
{
5873+
"title" : "Bug fixes",
5874+
"text" : "Removing custom object fields won't now prevent the parent object from being deleted."
5875+
}
5876+
}
58665877
}
58675878
}
58685879
},

data/whats-new.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<whatsnew>
22

3+
<version id="2.6.14">
4+
<item id="bugs" onlyIfCurrentVersion="true" />
5+
</version>
6+
37
<version id="2.6.13">
48
<item id="bugs" onlyIfCurrentVersion="true" />
59
</version>

src/com/quollwriter/db/ObjectManager.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,25 @@ public void deleteObject (DataObject d,
13891389

13901390
}
13911391

1392+
private void deleteAllUserConfigurableObjectFieldsForObject (UserConfigurableObject obj,
1393+
Connection conn)
1394+
throws GeneralException
1395+
{
1396+
1397+
UserConfigurableObjectFieldDataHandler dh = (UserConfigurableObjectFieldDataHandler) this.getHandler (UserConfigurableObjectField.class); //this.handlers.get (d.getClass ().getName ());
1398+
1399+
if (dh == null)
1400+
{
1401+
1402+
throw new GeneralException ("Class is not supported.");
1403+
1404+
}
1405+
1406+
dh.deleteAllFieldsForObject (obj,
1407+
conn);
1408+
1409+
}
1410+
13921411
public void deleteObject (DataObject d,
13931412
boolean deleteChildObjects,
13941413
Connection conn)
@@ -1440,6 +1459,9 @@ public void deleteObject (DataObject d,
14401459
this.deleteObjects (o.getFields (),
14411460
conn);
14421461

1462+
this.deleteAllUserConfigurableObjectFieldsForObject (o,
1463+
conn);
1464+
14431465
}
14441466

14451467
dh.deleteObject (d,

src/com/quollwriter/db/UserConfigurableObjectFieldDataHandler.java

Lines changed: 84 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class UserConfigurableObjectFieldDataHandler implements DataHandler<UserC
1212
{
1313

1414
private static final String STD_SELECT_PREFIX = "SELECT dbkey, userobjecttypefielddbkey, value, name, description, markup, lastmodified, datecreated, properties, id, version FROM userobjectfield_v ";
15-
15+
1616
private ObjectManager objectManager = null;
1717

1818
public UserConfigurableObjectFieldDataHandler (ObjectManager om)
@@ -22,6 +22,51 @@ public UserConfigurableObjectFieldDataHandler (ObjectManager om)
2222

2323
}
2424

25+
public void deleteAllFieldsForObject (UserConfigurableObject obj,
26+
Connection conn)
27+
{
28+
29+
List<UserConfigurableObjectField> ret = new ArrayList ();
30+
31+
try
32+
{
33+
34+
List params = new ArrayList ();
35+
params.add (obj.getKey ());
36+
37+
ResultSet rs = this.objectManager.executeQuery ("SELECT dbkey FROM userobjectfield_v WHERE namedobjectdbkey = ?",
38+
params,
39+
conn);
40+
41+
// Create a fake field.
42+
UserConfigurableObjectType _t = new UserConfigurableObjectType ();
43+
_t.setAssetObjectType (true);
44+
_t.setKey (1l);
45+
TextUserConfigurableObjectTypeField _tf = new TextUserConfigurableObjectTypeField ();
46+
_tf.setUserConfigurableObjectType (_t);
47+
48+
while (rs.next ())
49+
{
50+
51+
UserConfigurableObjectField _f = new UserConfigurableObjectField (_tf);
52+
53+
_f.setKey (rs.getLong (1));
54+
55+
this.objectManager.deleteObject (_f,
56+
true,
57+
conn);
58+
59+
}
60+
61+
} catch (Exception e) {
62+
63+
Environment.logError ("Unable to delete object fields: " + obj.getKey (),
64+
e);
65+
66+
}
67+
68+
}
69+
2570
private UserConfigurableObjectField getUserConfigurableObjectField (ResultSet rs,
2671
UserConfigurableObject parent,
2772
boolean loadChildObjects)
@@ -34,37 +79,37 @@ private UserConfigurableObjectField getUserConfigurableObjectField (ResultSet
3479
int ind = 1;
3580

3681
long key = rs.getLong (ind++);
37-
82+
3883
long typekey = rs.getLong (ind++);
39-
84+
4085
UserConfigurableObjectTypeField tf = (UserConfigurableObjectTypeField) Environment.getUserConfigurableObjectTypeField (typekey);
4186

4287
if (tf == null)
4388
{
44-
89+
4590
// This isn't an error, the field may have been removed without the requesting project knowing about
4691
// the deletion.
4792
return null;
48-
93+
4994
}
50-
95+
5196
UserConfigurableObjectField f = new UserConfigurableObjectField (tf);
52-
97+
5398
f.setKey (key);
5499

55100
String v = rs.getString (ind++);
56-
101+
57102
if (v != null)
58103
{
59-
104+
60105
f.setValue (tf.getViewEditHandler (parent,
61106
f,
62107
null).stringToValue (v));
63108

64109
}
65-
110+
66111
f.setName (rs.getString (ind++));
67-
112+
68113
f.setDescription (new StringWithMarkup (rs.getString (ind++),
69114
rs.getString (ind++)));
70115
f.setLastModified (rs.getTimestamp (ind++));
@@ -73,7 +118,7 @@ private UserConfigurableObjectField getUserConfigurableObjectField (ResultSet
73118
f.setId (rs.getString (ind++));
74119
f.setVersion (rs.getString (ind++));
75120
f.setParent (parent);
76-
121+
77122
return f;
78123

79124
} catch (Exception e)
@@ -115,11 +160,11 @@ public List<UserConfigurableObjectField> getObjects (UserConfigurableObject pare
115160

116161
if (f != null)
117162
{
118-
119-
ret.add (f);
120-
163+
164+
ret.add (f);
165+
121166
}
122-
167+
123168
}
124169

125170
try
@@ -139,7 +184,7 @@ public List<UserConfigurableObjectField> getObjects (UserConfigurableObject pare
139184
e);
140185

141186
}
142-
187+
143188
return ret;
144189

145190
}
@@ -201,57 +246,57 @@ public void createObject (UserConfigurableObjectField t,
201246

202247
if (t.getParent () == null)
203248
{
204-
249+
205250
throw new GeneralException ("The parent user configurable object must be specified for the field: " +
206251
t);
207-
252+
208253
}
209-
254+
210255
if (t.getUserConfigurableObjectTypeField () == null)
211256
{
212-
257+
213258
throw new GeneralException ("The object type field must be specified for field: " +
214259
t);
215-
216-
}
217-
260+
261+
}
262+
218263
List params = new ArrayList ();
219264
params.add (t.getKey ());
220265
params.add (t.getUserConfigurableObjectTypeField ().getKey ());
221266
params.add (t.getParent ().getKey ());
222-
267+
223268
params.add (t.getUserConfigurableObjectTypeField ().getViewEditHandler (t.getParentObject (),
224269
t,
225270
null).valueToString (t.getValue ()));
226-
271+
227272
this.objectManager.executeStatement ("INSERT INTO userobjectfield (dbkey, userobjecttypefielddbkey, namedobjectdbkey, value) VALUES (?, ?, ?, ?)",
228273
params,
229274
conn);
230275

231276
}
232277

233278
public void deleteObject (UserConfigurableObjectField t,
234-
boolean deleteChildObjects,
279+
boolean deleteChildObjects,
235280
Connection conn)
236281
throws GeneralException
237282
{
238283

239284
Set<String> filesToDelete = new HashSet ();
240-
285+
241286
for (String fn : t.getProjectFileNames ())
242287
{
243-
288+
244289
if (fn == null)
245290
{
246-
291+
247292
continue;
248-
293+
249294
}
250-
295+
251296
filesToDelete.add (fn);
252-
297+
253298
}
254-
299+
255300
List params = new ArrayList ();
256301
params.add (t.getKey ());
257302

@@ -261,9 +306,9 @@ public void deleteObject (UserConfigurableObjectField t,
261306

262307
for (String fn : filesToDelete)
263308
{
264-
309+
265310
this.objectManager.getProject ().deleteFile (fn);
266-
311+
267312
}
268313

269314
}
@@ -275,18 +320,18 @@ public void updateObject (UserConfigurableObjectField t,
275320

276321
List params = new ArrayList ();
277322

278-
323+
279324
String val = t.getUserConfigurableObjectTypeField ().getViewEditHandler (t.getParentObject (),
280325
t,
281326
null).valueToString (t.getValue ());
282327
params.add (val);
283-
328+
284329
params.add (t.getKey ());
285330

286331
this.objectManager.executeStatement ("UPDATE userobjectfield SET value = ? WHERE dbkey = ?",
287332
params,
288333
conn);
289-
334+
290335
}
291336

292337
}

0 commit comments

Comments
 (0)