use of org.openntf.domino.design.DesignBase in project org.openntf.domino by OpenNTF.
the class DesignClassTest method testDesignClass.
// @Test
public void testDesignClass() throws IOException {
Session sess = Factory.getSession(SessionType.CURRENT);
// Database db = sess.getDatabase("D:/Daten/notesdaten_9/localdb/empty.ns9");
// Database db = sess.getDatabase("D:/Daten/notesdaten_9/empty2.nsf");
// Database db = sess.getDatabase("D:/Daten/notesdaten_9/localdb/proglib4work2.nsf");
Database db = sess.getDatabase("srv-01-ndev2!!entwicklung/alex/proglib4work22.nsf");
testDb(db);
DatabaseDesign design = db.getDesign();
// -X = no AgentData
DesignCollection<DesignBase> elems = design.getDesignElements(//
"!@Contains($Flags;{X}) & !($TITLE={WEB-INF/classes/plugin/Activator.class}:{$BEProfileR7}) " + "");
// + "& @IsAvailable($ACLDigest) ");
// + "& @contains($TITLE;{gadproxy}) ");
System.out.println("Count: " + elems.getCount());
Path root = Paths.get("D:/daten/temp/ods3");
OnDiskProject odp = new OnDiskProject(root);
// PrintWriter pw = new PrintWriter(oFile);
for (DesignBase elem : elems) {
// + elem.getDocument().getItemValueString("$FLAGS"));
try {
odp.export(elem);
// //elem.getDxlString(null)
// String odp = elem.getOnDiskPath();
// if (StringUtil.isEmpty(odp)) {
// odp = elem.getNoteID() + ".note";
// }
// File odsFile = new File(root, odp);
// System.out.println(elem.getClass().getName() + "\t\t\t" + odsFile);
// odsFile.getParentFile().mkdirs(); // ensure the path exists
// elem.writeOnDiskFile(odsFile);
// if (elem instanceof HasMetadata) {
// File meta = new File(odsFile.getAbsolutePath() + ".metadata");
// ((HasMetadata) elem).writeOnDiskMeta(meta);
// }
} catch (Exception ne) {
ne.printStackTrace();
}
// String path = "./" + elem.getOnDiskPath();
// String ext = elem.getOnDiskExtension();
// if (path != null && ext != null && !path.endsWith(ext))
// path = path + ext;
// pw.println(path + "\t'" + elem.getClass().getSimpleName() + "\t" + elem.getNoteID() + "\t" + elem.getName() + "\t"
// + elem.getDocument().getItemValueString("$FLAGS"));
// if (elem instanceof HasMetadata) {
// pw.println(path + ".metadata");
// }
// if (elem instanceof CustomControl) {
// pw.println(path + "-config");
// }
}
}
use of org.openntf.domino.design.DesignBase in project org.openntf.domino by OpenNTF.
the class DesignClassTest method testDb.
protected void testDb(final Database db) {
DatabaseDesign design = db.getDesign();
System.out.println("Design: " + design.getClass().getName());
DesignCollection<DesignBase> allDesign = design.getDesignElements("@ALL");
Map<Class<?>, AtomicInteger> counter = new HashMap<Class<?>, AtomicInteger>();
for (DesignBase des : allDesign) {
if (!counter.containsKey(des.getClass())) {
counter.put(des.getClass(), new AtomicInteger());
}
counter.get(des.getClass()).incrementAndGet();
}
int i = 0;
int j = 0;
for (ODPMapping mapping : ODPMapping.values()) {
Class<? extends DesignBase> cls = mapping.getInstanceClass();
if (cls == OtherDesignElement.class) {
} else {
DesignCollection<? extends DesignBase> ret = design.getDesignElements(cls);
j = 0;
for (@SuppressWarnings("unused") DesignBase b : ret) {
i++;
j++;
}
int cnt;
if (!counter.containsKey(cls)) {
cnt = 0;
} else {
cnt = counter.get(cls).get();
}
if (j == cnt) {
System.out.println(j + "\t " + cnt + "\t" + cls.getName());
} else {
System.err.println(j + "\t " + cnt + "\t" + cls.getName());
}
// if (j == 0)
// System.err.println("No design element of " + cls.getName() + " found");
}
}
System.out.println("Total design elements " + i);
}
Aggregations