if (DAO.getRepositoryVersion()==null) {
createAllModules();
}
AtrilSession oSess = DAO.getAdminSession(getClass().getName()+".createDataModel");
Dms oDms = oSess.getDms();
InternationalizationManager oInm = oDms.getInternationalizationManager();
Locale oES = new Locale("es", "ES");
createTypeHierarchy(oDms, oDms.getRootType(), new String[]{"Configurations","Endorsements","Endorsement"});
createTypeHierarchy(oDms, oDms.getRootType(), new String[]{"Deposits","Deposit","Document","Side"});
createTypeHierarchy(oDms, oDms.getRootType(), new String[]{"CaptureTypes","CaptureType","Fields","Field"});
createTypeHierarchy(oDms, oDms.getDocumentType("CaptureType"), new String[]{"Scanner"});
createTypeHierarchy(oDms, oDms.getRootType(), new String[]{"DeviceInformationType"});
createTypeHierarchy(oDms, oDms.getRootType(), new String[]{"Zesped","CustomerAccount","TaxPayers","TaxPayer","Invoices","Invoice","InvoiceThumbnail"});
createTypeHierarchy(oDms, oDms.getRootType(), new String[]{"Zesped","CaptureServiceFlavor"});
createTypeHierarchy(oDms, oDms.getRootType(), new String[]{"Zesped","Countries","Country","States","State","Cities","City"});
createTypeHierarchy(oDms, oDms.getRootType(), new String[]{"Zesped","VatPercents","VatPercent"});
createTypeHierarchy(oDms, oDms.getDocumentType("Zesped"), new String[]{"Users","User","AllowedTaxPayers","AllowedTaxPayer"});
createTypeHierarchy(oDms, oDms.getDocumentType("User"), new String[]{"DeniedTaxPayers","DeniedTaxPayer"});
createTypeHierarchy(oDms, oDms.getDocumentType("Zesped"), new String[]{"Messages","Message"});
createTypeHierarchy(oDms, oDms.getDocumentType("Zesped"), new String[]{"Products","Product"});
createTypeHierarchy(oDms, oDms.getDocumentType("Zesped"), new String[]{"AccountingAccountsDefaults","AccountingAccountDefault"});
createTypeHierarchy(oDms, oDms.getDocumentType("CustomerAccount"), new String[]{"Orders","Order","OrderLine"});
createTypeHierarchy(oDms, oDms.getDocumentType("CustomerAccount"), new String[]{"Clients","Client"});
createTypeHierarchy(oDms, oDms.getDocumentType("CustomerAccount"), new String[]{"CustomerAccountCredits"});
createTypeHierarchy(oDms, oDms.getDocumentType("TaxPayer"), new String[]{"BillNotes","BillNote","Ticket","TicketThumbnail"});
createTypeHierarchy(oDms, oDms.getDocumentType("TaxPayer"), new String[]{"Employees","Employee"});
createTypeHierarchy(oDms, oDms.getDocumentType("TaxPayer"), new String[]{"AccountingAccounts","AccountingAccount"});
createTypeHierarchy(oDms, oDms.getDocumentType("TaxPayer"), new String[]{"IncomingDeposits"});
addTypeAttributes(oSess, oDms.getDocumentType("AccountingAccount"), new AccountingAccount().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("AccountingAccountDefault"), new AccountingAccountDefault().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("AllowedTaxPayer"), new AllowedTaxPayer().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("CaptureServiceFlavor"), new CaptureServiceFlavor().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("CaptureTypes"), new CaptureTypes().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("CaptureType"), new CaptureType().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("BillNote"), new BillNote().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("City"), new City().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Client"), new Client().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Country"), new Country().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("CustomerAccount"), new CustomerAccount().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("CustomerAccountCredits"), new CustomerAccountCredits().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("DeniedTaxPayer"), new DeniedTaxPayer().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Deposit"), new Deposit().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Deposits"), new Deposits().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("DeviceInformationType"), new DeviceInformationType().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Document"), new com.zesped.model.Document().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Employee"), new Employee().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Endorsement"), new Endorsement().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Field"), new Field().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Invoice"), new Invoice().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("InvoiceThumbnail"), new InvoiceThumbnail().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Message"), new Message().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Order"), new Order().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("OrderLine"), new OrderLine().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Product"), new Product().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Scanner"), new Scanner().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Side"), new Side().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("State"), new State().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("TaxPayer"), new TaxPayer().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("Ticket"), new Ticket().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("TicketThumbnail"), new TicketThumbnail().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("User"), new User().attributes());
addTypeAttributes(oSess, oDms.getDocumentType("VatPercent"), new VatPercent().attributes());
oInm.setCaptionFormat(oDms.getDocumentType("Zesped"), Locale.ENGLISH, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Zesped"), oES, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("CaptureServiceFlavor"), Locale.ENGLISH, "{id}");
oInm.setCaptionFormat(oDms.getDocumentType("CaptureServiceFlavor"), oES, "{id}");
oInm.setCaptionFormat(oDms.getDocumentType("TaxPayers"), Locale.ENGLISH, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("TaxPayers"), oES, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Invoices"), Locale.ENGLISH, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Invoices"), oES, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Country"), Locale.ENGLISH, "{en}");
oInm.setCaptionFormat(oDms.getDocumentType("Country"), oES, "{es}");
oInm.setCaptionFormat(oDms.getDocumentType("State"), Locale.ENGLISH, "{name}");
oInm.setCaptionFormat(oDms.getDocumentType("State"), oES, "{name}");
oInm.setCaptionFormat(oDms.getDocumentType("City"), Locale.ENGLISH, "{name}");
oInm.setCaptionFormat(oDms.getDocumentType("City"), oES, "{name}");
oInm.setCaptionFormat(oDms.getDocumentType("Users"), Locale.ENGLISH, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Users"), oES, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("VatPercent"), Locale.ENGLISH, "{percentage} {description}");
oInm.setCaptionFormat(oDms.getDocumentType("VatPercent"), oES, "{percentage} {description}");
oInm.setCaptionFormat(oDms.getDocumentType("AccountingAccountsDefaults"), Locale.ENGLISH, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("AccountingAccountsDefaults"), oES, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("AccountingAccountDefault"), Locale.ENGLISH, "{account_code} - {account_desc}");
oInm.setCaptionFormat(oDms.getDocumentType("AccountingAccountDefault"), oES, "{account_code} - {account_desc}");
oInm.setCaptionFormat(oDms.getDocumentType("Messages"), Locale.ENGLISH, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Messages"), oES, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Products"), Locale.ENGLISH, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Products"), oES, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Orders"), Locale.ENGLISH, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Orders"), oES, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Clients"), Locale.ENGLISH, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Clients"), oES, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("BillNotes"), Locale.ENGLISH, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("BillNotes"), oES, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Employees"), Locale.ENGLISH, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Employees"), oES, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("Employee"), Locale.ENGLISH, "{employee_name} ({employee_id})");
oInm.setCaptionFormat(oDms.getDocumentType("Employee"), oES, "{employee_name} ({employee_id})");
oInm.setCaptionFormat(oDms.getDocumentType("AccountingAccounts"), Locale.ENGLISH, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("AccountingAccounts"), oES, "{#TypeName}");
oInm.setCaptionFormat(oDms.getDocumentType("AccountingAccount"), Locale.ENGLISH, "{account_code} - {account_desc}");
oInm.setCaptionFormat(oDms.getDocumentType("AccountingAccount"), oES, "{account_code} - {account_desc}");
oInm.setCaptionFormat(oDms.getDocumentType("CustomerAccount"), Locale.ENGLISH, "{business_name}");
oInm.setCaptionFormat(oDms.getDocumentType("CustomerAccount"), oES, "{business_name}");
oInm.setCaptionFormat(oDms.getDocumentType("CustomerAccountCredits"), Locale.ENGLISH, "Used {credits_used} Left {credits_left}");
oInm.setCaptionFormat(oDms.getDocumentType("CustomerAccountCredits"), oES, "Usados {credits_used} Disponibles {credits_left}");
oInm.setCaptionFormat(oDms.getDocumentType("Order"), Locale.ENGLISH, "{order_id} / {creation_date}");
oInm.setCaptionFormat(oDms.getDocumentType("Order"), oES, "{order_id} / {creation_date}");
oInm.setCaptionFormat(oDms.getDocumentType("OrderLine"), Locale.ENGLISH, "{line_num}: {product_name}");
oInm.setCaptionFormat(oDms.getDocumentType("OrderLine"), oES, "{line_num}: {product_name}");
oInm.setCaptionFormat(oDms.getDocumentType("TaxPayer"), Locale.ENGLISH, "{business_name} ({tax_id})");
oInm.setCaptionFormat(oDms.getDocumentType("TaxPayer"), oES, "{business_name} ({tax_id})");
oInm.setCaptionFormat(oDms.getDocumentType("Client"), Locale.ENGLISH, "{business_name} ({tax_id})");
oInm.setCaptionFormat(oDms.getDocumentType("Client"), oES, "{business_name} ({tax_id})");
oInm.setCaptionFormat(oDms.getDocumentType("Invoice"), Locale.ENGLISH, "{invoice_number}");
oInm.setCaptionFormat(oDms.getDocumentType("Invoice"), oES, "{invoice_number}");
oInm.setCaptionFormat(oDms.getDocumentType("BillNote"), Locale.ENGLISH, "{employee_name} {comments}");
oInm.setCaptionFormat(oDms.getDocumentType("BillNote"), oES, "{employee_name} {comments}");
oInm.setCaptionFormat(oDms.getDocumentType("Ticket"), Locale.ENGLISH, "{ticket_date} {comments}");
oInm.setCaptionFormat(oDms.getDocumentType("Ticket"), oES, "{ticket_date} {comments}");
oInm.setCaptionFormat(oDms.getDocumentType("User"), Locale.ENGLISH, "{email}");
oInm.setCaptionFormat(oDms.getDocumentType("User"), oES, "{email}");
oInm.setCaptionFormat(oDms.getDocumentType("Message"), Locale.ENGLISH, "{message_subject}");
oInm.setCaptionFormat(oDms.getDocumentType("Message"), oES, "{message_subject}");
oInm.setCaptionFormat(oDms.getDocumentType("Product"), Locale.ENGLISH, "{product_name}");
oInm.setCaptionFormat(oDms.getDocumentType("Product"), oES, "{product_name} ({price} {currency})");
oInm.setCaptionFormat(oDms.getDocumentType("CaptureType"), Locale.ENGLISH, "{name}");
oInm.setCaptionFormat(oDms.getDocumentType("CaptureType"), oES, "{name}");
oInm.setCaptionFormat(oDms.getDocumentType("DeviceInformationType"), Locale.ENGLISH, "{brand} {model}");
oInm.setCaptionFormat(oDms.getDocumentType("DeviceInformationType"), oES, "{brand} {model}");
DocumentType oDepT = oDms.getDocumentType("Deposit");
DocumentType oSidT = oDms.getDocumentType("Side");
DocumentType oInvT = oDms.getDocumentType("Invoice");
DocumentType oTckT = oDms.getDocumentType("Ticket");
DocumentType oIncT = oDms.getDocumentType("IncomingDeposits");
try {
oSidT.addParent(oInvT);
oSidT.save();
} catch (IllegalArgumentException yaespadre) { }
try {
oSidT.addParent(oTckT);
oSidT.save();
} catch (IllegalArgumentException yaespadre) { }
try {
oDepT.addParent(oIncT);
oDepT.save();
} catch (IllegalArgumentException yaespadre) { }
oSess.commit();
String sMountBase = "/usr/local/apache-tomcat-6.0.36/webapps/zesped/WEB-INF/volumes/"; // DAO.getVolumesMountBase();
if (sMountBase.length()>0) {
boolean bDefaultVolumeExists = false;
VolumeManager oVolm = oDms.getVolumeManager();
for (Volume v : oVolm.getVolumeList()) {
bDefaultVolumeExists = v.name().equals("Default");
if (bDefaultVolumeExists) break;
}
if (!bDefaultVolumeExists) {
sMountBase = Gadgets.chomp(sMountBase, File.separator);
FileSystem oFs = new FileSystem();
try {
oFs.mkdirs("file://"+sMountBase+"default");
} catch (Exception e) {
throw new FileNotFoundException("Could not create directory "+sMountBase+"default");
}
if (!new File(sMountBase).exists()) throw new FileNotFoundException("Could not create directory "+sMountBase+"default");
Volume oVol = oVolm.createVolume("Default", sMountBase, "default", 20*1048576);
oVol.setTotalSpace(100*1048576);
oVol.setDescription("Default Zesped Volume");
oVol.setMounted(true);
oVol.setUsable(true);
oVol.setMaxDirectories(1000);
oVol.setMaxFiles(1000);
oVol.save();
oSess.commit();
}
}
oSess.disconnect();
oSess.close();
} // createDataModel