Revision 44262 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/TableManager.java
TableManager.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
package org.gvsig.app.project.documents.table; |
26 | 26 |
|
27 |
import java.util.Collections; |
|
27 | 28 |
import java.util.Iterator; |
28 | 29 |
import java.util.List; |
30 |
import java.util.Map; |
|
31 |
import java.util.function.Function; |
|
29 | 32 |
|
30 | 33 |
import javax.swing.ImageIcon; |
34 |
import org.apache.commons.lang3.StringUtils; |
|
31 | 35 |
|
32 | 36 |
import org.gvsig.andami.IconThemeHelper; |
33 | 37 |
import org.gvsig.andami.PluginServices; |
... | ... | |
63 | 67 |
import org.gvsig.tools.dynobject.DynStruct; |
64 | 68 |
import org.gvsig.tools.evaluator.Evaluator; |
65 | 69 |
import org.gvsig.tools.persistence.PersistenceManager; |
66 |
import org.gvsig.tools.util.GetItemByKey; |
|
70 |
import org.gvsig.tools.util.MappedIterator; |
|
71 |
import org.gvsig.tools.util.UnmodifiableBasicMap; |
|
72 |
import org.gvsig.tools.util.UnmodifiableBasicSet; |
|
73 |
import org.gvsig.tools.util.UnmodifiableBasicSetMapped; |
|
67 | 74 |
|
68 | 75 |
/** |
69 | 76 |
* Factory of Table. |
... | ... | |
74 | 81 |
*/ |
75 | 82 |
public class TableManager extends AbstractDocumentManager { |
76 | 83 |
|
77 |
private static class TableDocumentStoresRepository implements GetItemByKey<String,DataStoreParameters> {
|
|
84 |
private static class TableDocumentStoresRepository implements UnmodifiableBasicMap<String,DataStoreParameters> {
|
|
78 | 85 |
|
79 | 86 |
@Override |
80 | 87 |
public DataStoreParameters get(String name) { |
... | ... | |
85 | 92 |
} |
86 | 93 |
return tableDoc.getFeatureStore().getParameters(); |
87 | 94 |
} |
95 |
|
|
96 |
@Override |
|
97 |
public boolean containsKey(String key) { |
|
98 |
Project project = ProjectManager.getInstance().getCurrentProject(); |
|
99 |
for (Document document : project.getDocuments(TableManager.TYPENAME)) { |
|
100 |
if( StringUtils.equalsIgnoreCase(key, document.getName()) ) { |
|
101 |
return true; |
|
102 |
} |
|
103 |
} |
|
104 |
return false; |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
108 |
public UnmodifiableBasicSet<String> keySet() { |
|
109 |
Project project = ProjectManager.getInstance().getCurrentProject(); |
|
110 |
List<Document> docs = project.getDocuments(TableManager.TYPENAME); |
|
111 |
if( docs==null ) { |
|
112 |
return UnmodifiableBasicSet.EMPTY_UNMODIFIABLEBASICSET; |
|
113 |
} |
|
114 |
return new UnmodifiableBasicSetMapped<>(docs, new Function<Document, String>() { |
|
115 |
@Override |
|
116 |
public String apply(Document t) { |
|
117 |
return t.getName(); |
|
118 |
} |
|
119 |
}); |
|
120 |
} |
|
121 |
|
|
122 |
@Override |
|
123 |
public Map<String, DataStoreParameters> toMap() { |
|
124 |
return null; |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public boolean isEmpty() { |
|
129 |
Project project = ProjectManager.getInstance().getCurrentProject(); |
|
130 |
return project.getDocuments(TableManager.TYPENAME).isEmpty(); |
|
131 |
} |
|
132 |
|
|
133 |
@Override |
|
134 |
public int size() { |
|
135 |
Project project = ProjectManager.getInstance().getCurrentProject(); |
|
136 |
int sz = project.getDocuments(TableManager.TYPENAME).size(); |
|
137 |
return sz; |
|
138 |
} |
|
139 |
|
|
140 |
@Override |
|
141 |
public Iterator<DataStoreParameters> iterator() { |
|
142 |
Project project = ProjectManager.getInstance().getCurrentProject(); |
|
143 |
List<Document> docs = project.getDocuments(TableManager.TYPENAME); |
|
144 |
if( docs==null ) { |
|
145 |
return Collections.EMPTY_LIST.iterator(); |
|
146 |
} |
|
147 |
return new MappedIterator<>(docs.iterator(), new Function<Document, DataStoreParameters>() { |
|
148 |
@Override |
|
149 |
public DataStoreParameters apply(Document t) { |
|
150 |
return ((TableDocument)t).getFeatureStore().getParameters(); |
|
151 |
} |
|
152 |
}); |
|
153 |
} |
|
88 | 154 |
|
155 |
|
|
89 | 156 |
} |
90 | 157 |
|
91 | 158 |
public static final String PERSISTENCE_TABLE_DOCUMENT_DEFINITION_NAME = |
Also available in: Unified diff