~berthold-daum/zora/trunk

« back to all changes in this revision

Viewing changes to com.bdaum.zoom.core/src/com/bdaum/zoom/core/internal/Utilities.java

  • Committer: bdaum
  • Date: 2015-12-26 10:21:51 UTC
  • Revision ID: berthold.daum@bdaum.de-20151226102151-44f1j5113167thb9
VersionĀ 2.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
import org.eclipse.core.runtime.FileLocator;
46
46
import org.eclipse.core.runtime.Path;
47
47
import org.eclipse.core.runtime.Platform;
48
 
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
49
48
import org.eclipse.osgi.util.NLS;
50
 
import org.osgi.service.prefs.BackingStoreException;
51
49
 
52
50
import com.bdaum.zoom.cat.model.Meta_type;
53
51
import com.bdaum.zoom.cat.model.asset.Asset;
92
90
                SmartCollection ncoll = new SmartCollectionImpl(scoll.getName(),
93
91
                                scoll.getSystem(), scoll.getAlbum(), scoll.getAdhoc(), false,
94
92
                                scoll.getDescription(), scoll.getColorCode(),
95
 
                                scoll.getLastAccessDate(), scoll.getGeneration() + 1,
 
93
                                scoll.getLastAccessDate(), scoll.getGeneration() + 1, scoll.getPerspective(),
96
94
                                scoll.getPostProcessor());
97
95
                for (Criterion crit : scoll.getCriterion())
98
96
                        ncoll.addCriterion(crit);
578
576
                String label = category.getLabel();
579
577
                SmartCollectionImpl coll = new SmartCollectionImpl(
580
578
                                label.length() > 0 ? label : Messages.Utilities_not_categorized,
581
 
                                true, false, false, false, null, 0, null, 0, null);
 
579
                                true, false, false, false, null, 0, null, 0, null, null);
582
580
                coll.setStringId(IDbManager.CATKEY + label);
583
581
                Criterion crit = new CriterionImpl(QueryField.IPTC_CATEGORY.getKey(),
584
582
                                null, label, QueryField.EQUALS, false);
905
903
                for (int i = -1; i <= 5; i++) {
906
904
                        SmartCollectionImpl coll = new SmartCollectionImpl(
907
905
                                        (i < 0) ? Messages.CoreActivator_Not_rated : STARS[i],
908
 
                                        true, false, false, false, null, 0, null, 0, null);
 
906
                                        true, false, false, false, null, 0, null, 0, null, null);
909
907
                        coll.setStringId(prefix + i);
910
908
                        CriterionImpl crit = new CriterionImpl(ratingKey, null, i,
911
909
                                        QueryField.EQUALS, false);
1111
1109
                        for (String rid : group.getRootCollection()) {
1112
1110
                                SmartCollectionImpl last = dbManager.obtainById(
1113
1111
                                                SmartCollectionImpl.class, rid);
1114
 
                                if (last != null && !force && !isEmpty(dbManager, last)) {
 
1112
                                if (last != null && !force && !isImportEmpty(dbManager, last)) {
1115
1113
                                        empty = false;
1116
1114
                                        continue;
1117
1115
                                }
1156
1154
                return true;
1157
1155
        }
1158
1156
 
1159
 
        public static boolean isEmpty(IDbManager dbManager, SmartCollectionImpl sm) {
 
1157
        public static boolean isImportEmpty(IDbManager dbManager, SmartCollectionImpl sm) {
1160
1158
                if (sm.getSubSelection().isEmpty()) {
1161
1159
                        Criterion criterion = sm.getCriterion(0);
1162
1160
                        Object value = criterion.getValue();
1169
1167
                        else
1170
1168
                                set = dbManager.obtainObjects(AssetImpl.class, field, value,
1171
1169
                                                QueryField.EQUALS);
1172
 
                        return set.isEmpty();
 
1170
                        return !set.iterator().hasNext();
1173
1171
                }
1174
1172
                return false;
1175
1173
        }
1286
1284
                return copy;
1287
1285
        }
1288
1286
 
1289
 
        public static void putPreferences(IEclipsePreferences node, String key,
1290
 
                        String value) {
1291
 
                node.put(key, value);
1292
 
                try {
1293
 
                        node.flush();
1294
 
                } catch (BackingStoreException e1) {
1295
 
                        // should never happen
1296
 
                }
1297
 
        }
1298
 
 
1299
1287
        public static String[] computeBackupLocation(File catFile,
1300
1288
                        String backupLocation) {
1301
1289
                String generationFolder = null;