Hi in my project we are doing an import if lets say products.
We will have a web service where we will get maybe 10 calls for one import, so we need to have a transaction that can be over several requests.
The import will have both new products that needs to be created and existing products that needs to be updated.
Right now the only way we can know if the product is already in our system or not is to look at Name or Previous Name on the Product we want to import.
So basically my questions is.
Can the transaction API described here http://ravendb.net/docs/client-api/advanced/databasecommands, Be used for the Batch api described here http://ravendb.net/docs/1.0/client-api/advanced/databasecommands/batch. (which it sounds not to work together if one read the batch api documentation).
And if not should I use the database commands connected with an transaction? But in the documentation for databasecommands I can't see how the transaction guid and the operations can be connected?
The easiest way to handle that is to aggregate things in memory and have just a single SaveChanges call in the end.
Related
I've got a question regarding Spring Batch and reusability.
I'm working on a project which is composed of an online application developed with Spring Mvc and several batch processes developed with Spring Batch. Some of the online use cases are also executed in the batch processes.
For example, let's imagine that our online application is Spring's Sagan app and the online use case that we want to reuse in batch is createOrUpdateMemberProfile. From the online application a single member profile is created or updated in each request. However, in the the batch process lots of member profiles are created reading the information from a csv file.
To implement this, the first option is to keep createOrUpdateMemberProfile method as it is and develop new code for the batch process with Spring Batch using its ItemWriters and other elements. In this way I'm developing the use case two times, one for online transactions and the second for batch processes.
The second option is to reuse createOrUpdateMemberProfile method in the batch process with ItemWriterAdapter. In this way I'm reusing the online method, but I guess I'm losing some performance because I'm getting rid of chunk-oriented processing. Depending on the amount of member profiles to create from the csv file, it might be a bit risky.
The third, and last, option is to get rid of createOrUpdateMemberProfile method and implement the batch process with Spring Batch which be called from the online application as well. That is, the online application will launch the job, but instead of creating many member profiles it will create just one. In this way I'm reusing code, but it sounds really strange to me and I discard it beforehand.
Right now I'm keen on the second option but I wonder if I'm loosing something, apart from performance, or I'll struggle with another aspect that I'm not aware of. Any advice or suggestion will be appreciated.
Thanks.
I am bit confused about N-Unit Framework Testing. Below is my scenario for Web Application.
Create a Ticket
Assign a Ticket to User
Either User can work on Ticket or He may forward it for manager Approval.
Once Manager is Approved, he will work on that Ticket.
Close the Ticket.
How to create test case in N-Unit Framework. Below are my few questions.
Should i write code to create a Ticket? Can we insert a data to Database using N-Unit Framework.
If ticket is created, should we capture that ticket number and assign it to some user.
Should we write a code to assign it to user for approval?
I am not sure how to write N-Unit scripts for Wrokflow Logic.
When you write unit tests you usually write them so that they test one thing only. When testing a workflow you would typically split it up in several unit tests. In your scenario each point is a good candidate for a unit test except for number 3 that should be split up into at least two tests.
Should i write code to create a Ticket? Can we insert a data to
Database using N-Unit Framework.
It depends on your implementation. If you need a ticket for your tests then you have to create it first. No, you cannot use the NUnit framework to insert data into the database. That is not the kind of problem that the framework is intended to solve. Typically when writing unit tests you want to avoid accessing external resources like a database so try to write the code so that you don’t have to do that.
If ticket is created, should we capture that ticket number and
assign it to some user.
Should we write a code to assign it to user for approval?
This depends on how you have implemented the system. If you need this to run your tests, then yes.
I'm developing an ecommerce based on Websphere Commerce 7 WCS7. I need to import products from an external supplier, which is exposing a webservice. I've already implemented a Controller Command performing all the operation needed to extract the products from the remote service, and I've them avalaible as custom Java classes.
I'm a little bit confused about the approach I should follow in this case. I've defined the attributes needed in my scenario and used the dataload utility to import them in the DB. What should I do next? I expect to be able to "create" WCS product programmatically from my Controller Command but I don't know how to use the attribute I've defined in a programmatic insert.
Can someone point me on the right track on how to perform this kind of operation? I went through the documentation, but, given the fact I'm quite new of the WCS environment, I don't know how to proceed according to the current best practices.
It is possible to create a new catalog entry programmatically if you copy what is being done in the LOBTools. I have not done this myself though. I have always added new products via the data loads and when we did need to add from an external service I just output the information to a file and loaded along with our other products. The reason was due to keeping the catalog in sync with the product management system.
Have a look at the various DataBean classes in WCS, like: CatalogEntryDataBean.
See here for WCS data beans:Link
And here for "activation" of a DataBean:Link
Does anyone have experiences with programmatic exports of data in conjunction with BaaS providers like e.g. parse.com or StackMob?
I am aware that both providers (as far as I can tell from the marketing talk) offer a REST API which will allow for queries against the database, not only to be used by mobile clients but also by e.g. custom web apps.
I am also aware that both providers offer a manual export of data (parse.com via their web interface, StackMob via support).
But lets say I would like to dump all data nightly, so that I can import it into a reporting system for instance. Or maybe simply to have an up-to-date backup.
In this case, I would need a programmatic way to export/replicate the data stored in the backend. Manual exports are not an option for obvious reasons.
The REST APIs offered however seem to be designed for specific queries, not for mass reads (performance?). Let alone the pricing - I assume none of the providers would be happy about a nightly X Gigabyte data export via their REST API, so their probably will be a price tag.
I just couldn't find any specific information on this topic so far, so I was wondering if anyone else has already gone through this. Also, any suggestions on StackMob/parse alternatives are welcome, especially if related to the data export topic.
Cheers, Alex
Did you see the section of the Parse REST API on Batch operations? Batch operations reduce the number of API calls needed to grab data so that you are not using a call for every row you retrieve. Keep in mind that there is still a limit (the default is 100, but you can set it to a maximum of 1000). That means you are still limited to pulling down 1000 rows per API call.
I can't comment on StackMob because I haven't used it. At my present job, we are using Parse and we wrote a C# app which compares the data in a Parse class with a SQL table and pulls down any changes.
I have a REST service that serves Invoice functionality, for example I can create, update and delete an invoice via the REST service.
However I now need to have functionality to split an invoice into several new invoices, i.e. the method needs to create x invoices based on one invoice, and then delete the original invoice in one transaction.
I also need a merge method that does the opposite, i.e. multiple invoices merged into one.
How do I create such architect the RESTful way?
We had a similar issue where we wanted to merge 2 resources. After a long debate we decided that a consumer would POST a merge request resource which contained the 2 resources to be merged. Then after looking at it we decided that there was no need for both the complete source and target resource and instead a POST of just the unique identifier was sufficient. We didn't make the merge request with just the 2 ID's come in the body. It was easier to represent in a URL so that's what we did. The response from the POSTing of a merge request is the merged resource.
I guess I'm not a REST guru enough to tell you this was a good strategy or not, but for us it was a simple solution so we went with it.
When you say that want to implement this functionality in "one transaction" I assume you have already determined that you should combine generation of the new invoices and deletion of the old one, into one API call; which is the correct approach. With web services you do want to reduce chatter and there is probably some business logic on how this functionality will generate the new invoices and delete the old one. So I am assuming when you ask how to architect this in a RESTful way you are wondering which HTTP verb to use (i.e. GET, POST, PUT or DELETE) for this new API method. Usually these verbs map to CRUD type operations in the following manner:
Create -> POST
Read -> GET
Update -> PUT
Delete -> DELETE
So which verb to use when your function both creates and deletes records. A general rule with REST API's is if there is not a clear mapping to CRUD then use POST if there is a change to the server state and a GET if you are just returning information that does not change the server state. So in this case I would go with a POST.
If you are looking for additional guidance on architecting this please be more specific in what you are looking for and I will try to help.
I would do something like,
POST /InvoiceSplitter?sourceInvoiceId=99
and
POST /InvoiceMerger?sourceInvoiceIds=101,87,23,45