oSess.commit();
Dms oDms = oSess.getDms();
DocumentIndexer oIdx = oSess.getDocumentIndexer();
Document oZespedDoc = null;
UsersGroup oUsrsGrp = new UsersGroup(oAum, Zesped.getUsersGroup(oAum));
UsersGroup oOpersGrp = new UsersGroup(oAum, Zesped.getOperatorsGroup(oAum));
SortableList<Document> oLst = oDms.query("DeviceInformationType$brand='TWAIN'");
if (oLst.isEmpty()) {
Document oDit = oDms.newDocument(oDms.getDocumentType("DeviceInformationType"), oDms.getRootDocument());
oDit.attribute("model").set("TWAIN");
oDit.attribute("brand").set("TWAIN");
oDit.save("");
oSess.commit();
oUsrsGrp.grantReadOnly(oDit);
oOpersGrp.grantReadOnly(oDit);
oSess.commit();
}
oLst = oDms.query("Endorsement$endorsement_id='01'");
if (oLst.isEmpty()) {
Configurations oCnf = null;
try {
oCnf = Configurations.top(oSess);
} catch (ElementNotFoundException enfe) {
Document oDnf = oDms.newDocument(oDms.getDocumentType("Configurations"), oDms.getRootDocument());
oDnf.save("");
oSess.commit();
oCnf = new Configurations(oDnf);
oUsrsGrp.grantReadOnly(oDnf);
oOpersGrp.grantReadOnly(oDnf);
}
Document oEns = oDms.newDocument(oDms.getDocumentType("Endorsements"), oCnf.getDocument());
oEns.save("");
oSess.commit();
Document oEnd = oDms.newDocument(oDms.getDocumentType("Endorsement"), oEns);
oEnd.attribute("endorsement_id").set("01");
oEnd.attribute("endorsement_mask").set("JJJUUUSSS%03d");
oEnd.attribute("endorsement_text").set("Ipsa [date_dd/MM/yyyy] [Endorsement.endorsement_mask]");
oEnd.save("");
oSess.commit();
}
try {
oZespedDoc = Zesped.top(oSess).getDocument();
} catch (ElementNotFoundException enfe) {
oZespedDoc = createDocumentOfType(oIdx, oDms, "Zesped", oDms.getRootDocument());
oOpersGrp.grantAll(oZespedDoc);
}
try {
Users.top(oSess);
} catch (ElementNotFoundException enfe) {
createDocumentOfType(oIdx, oDms, "Users", oZespedDoc);
}
try {
Products.top(oSess);
} catch (ElementNotFoundException enfe) {
Document oProds = createDocumentOfType(oIdx, oDms, "Products", oZespedDoc);
oUsrsGrp.grantReadOnly(oProds);
}
try {
Countries.top(oSess);
} catch (ElementNotFoundException enfe) {
Document oCountries = createDocumentOfType(oIdx, oDms, "Countries", oZespedDoc);
oUsrsGrp.grantReadOnly(oCountries);
}
try {
AccountingAccountsDefaults.top(oSess);
} catch (ElementNotFoundException enfe) {
Document oAAccsDefs = createDocumentOfType(oIdx, oDms, "AccountingAccountsDefaults", oZespedDoc);
oUsrsGrp.grantReadOnly(oAAccsDefs);
}
try {
VatPercents.top(oSess);
} catch (ElementNotFoundException enfe) {
Document oVatPcts = createDocumentOfType(oIdx, oDms, "VatPercents", oZespedDoc);
oUsrsGrp.grantReadOnly(oVatPcts);
}
oSess.commit();
oSess.disconnect();