TL;DR version: We have an XML file cataloging things we need to track. It gets updated weekly (or sometimes more often depending on need). We need to display it in an organized fashion (a scrollable, sortable, filterable table and a detail view) to users. We also need to add/edit our own local catalog information and display it in the same UX. How would you way to deal with this requirement in a Java/Servlet environment? (We are extremely limited in what 'external' libraries, sources, etc. can be used. Currently on Solaris 10/11, with Java 1.6/1.7, Tomcat 5.5, NetBeans 6.7.1/7.1 and Oracle 10g/11 as the big pieces.)
Longer Version:
I've discussed this work before in various forum threads where I talked about pieces of what I'm doing.
If you care to look back:
viewtopic.php?f=20&t=1188025
viewtopic.php?f=20&t=1185786
viewtopic.php?f=20&t=1184030
viewtopic.php?f=20&t=1161866
viewtopic.php?f=20&t=1154130
We get an XML file weekly from an upstream provider. It is usually between 200 and 300mb in size. If the tempo of operations requires it, it is updated more frequently, but probably no more than daily. It contains a catalog of things we need to track, so far under 30K line-items.
We need to be able to:
Currently, we have a Java application which I wrote last year which everyone loves. It does the first four things. They want me to add the fifth bit as well, but they also want the system to me available more widely (right now, you have to have Java installed, with the application and get the XML file yourself.) So we're moving to a web-based implementation. I currently have an implemenation working inside Tomcat which works, for the most part. I have yet to add the sorting capability as well as the create/edit capability.
Another programmer is working on a VERY similar project (XML catalog of things provided by an upstream provider) which needs this same technology I'm working on. Instead of recreating the wheel, he keeps turning to me for help (which is understandable.) I'm hearing rumblings, though, that what I create may be the basis for applications from here on out...
So I don't want it to suck and I want to keep it simple so I can turn this over to other programmers to be understandable (I'm a contractor and could go away at any time.) Worse, I'm severely hampered by the inability to get external libraries, open source or otherwise, into the network(s) we need to run this program on. The approval process timespan takes months.
Right now the application is VERY tied to the data and the structure of the XML file.
What I have right now:
o ContextListener, running when the application starts or shuts down. Uses the JAXB Objects (created by NetBeans and the provided Schema Document(s) (XSD)) to read the XML file (location configured in web.xml) and parses it into Java data objects. Then it transforms those objects into custom data objects I wrote to meet the needs of the application. The parsed objects and the XML document are dropped and these custom data objects form the basis of my back-end 'database.'
o Data grid, an HTML table built by JSP, from data provided by a filter.
o Filter, both a web element and a back-end element, allowing users to filter the displayed items.
o DAO, iterates through the back-end 'database', creating a list of catalog items for display based on provided filter.
o Some simple JavaScript to handle clicks and what not; it is not doing any rendering.
o Various Servlet bits to tie the stuff together.
I've been trying different things to make it easier to 'generify' this solution, but it seems like to make it more generic (and simpler) I have to write more and more code.
I've tried to simplify my back-end database into a List<Map<String, Object>> to make it hugely generic, but then describing the data to the system requires a lot of mapping columns to properties/fields/keys just for display.
I thought I'd be clever and use JTables RowSorter to do all the heavy lifting with filtering and sorting, and this works as well, but now I have to somehow map user-provided values and RowFilters to columns. To make things even more complex, some columns are tied to other columns in a min/max value range arrangement which means that I have two filter values comparing themeselves to two target columns.
Yesterday, I thought that some of the stuff I was doing might be amenable to using XPath queries to generate my data, so I tested it out based on the simple demos floating around the 'net:
Reading and parsing the file in the first two lines takes about 10-15 seconds. Obviously, this is a one-time read in my current 'architecture.'
Performing the XPath query takes about 30 seconds ... not quite usable in a user-interactive environment.
This is where I am and how I've gotten here. I don't mind refactoring or asking for help or trying to get stuff approved for use; I just don't have the environment in which to (a) properly experiment. I've learned a lot and figured out even more, but I'm coming up on a mental roadblock as to where to proceed from here.
Thanks for your time reading this far...
Any help would be great.
Longer Version:
I've discussed this work before in various forum threads where I talked about pieces of what I'm doing.
If you care to look back:
viewtopic.php?f=20&t=1188025
viewtopic.php?f=20&t=1185786
viewtopic.php?f=20&t=1184030
viewtopic.php?f=20&t=1161866
viewtopic.php?f=20&t=1154130
We get an XML file weekly from an upstream provider. It is usually between 200 and 300mb in size. If the tempo of operations requires it, it is updated more frequently, but probably no more than daily. It contains a catalog of things we need to track, so far under 30K line-items.
We need to be able to:
* View a summary of the items in a user-friendly way, (currently a JTable or HTML Table)
* Search for items based on various field values (using JTable's built-in RowFilter)
* Sort based on various field values (using JTable's built-in RowSorter)
* View details about the filtered items (selection on the JTable shows details; double-click brings up browser window with details)
* Add a parallel 'database' which allows us to create/edit our own catalog items and treat them the same in this system.
Currently, we have a Java application which I wrote last year which everyone loves. It does the first four things. They want me to add the fifth bit as well, but they also want the system to me available more widely (right now, you have to have Java installed, with the application and get the XML file yourself.) So we're moving to a web-based implementation. I currently have an implemenation working inside Tomcat which works, for the most part. I have yet to add the sorting capability as well as the create/edit capability.
Another programmer is working on a VERY similar project (XML catalog of things provided by an upstream provider) which needs this same technology I'm working on. Instead of recreating the wheel, he keeps turning to me for help (which is understandable.) I'm hearing rumblings, though, that what I create may be the basis for applications from here on out...
So I don't want it to suck and I want to keep it simple so I can turn this over to other programmers to be understandable (I'm a contractor and could go away at any time.) Worse, I'm severely hampered by the inability to get external libraries, open source or otherwise, into the network(s) we need to run this program on. The approval process timespan takes months.
Right now the application is VERY tied to the data and the structure of the XML file.
What I have right now:
o ContextListener, running when the application starts or shuts down. Uses the JAXB Objects (created by NetBeans and the provided Schema Document(s) (XSD)) to read the XML file (location configured in web.xml) and parses it into Java data objects. Then it transforms those objects into custom data objects I wrote to meet the needs of the application. The parsed objects and the XML document are dropped and these custom data objects form the basis of my back-end 'database.'
o Data grid, an HTML table built by JSP, from data provided by a filter.
o Filter, both a web element and a back-end element, allowing users to filter the displayed items.
o DAO, iterates through the back-end 'database', creating a list of catalog items for display based on provided filter.
o Some simple JavaScript to handle clicks and what not; it is not doing any rendering.
o Various Servlet bits to tie the stuff together.
I've been trying different things to make it easier to 'generify' this solution, but it seems like to make it more generic (and simpler) I have to write more and more code.
I've tried to simplify my back-end database into a List<Map<String, Object>> to make it hugely generic, but then describing the data to the system requires a lot of mapping columns to properties/fields/keys just for display.
I thought I'd be clever and use JTables RowSorter to do all the heavy lifting with filtering and sorting, and this works as well, but now I have to somehow map user-provided values and RowFilters to columns. To make things even more complex, some columns are tied to other columns in a min/max value range arrangement which means that I have two filter values comparing themeselves to two target columns.
Yesterday, I thought that some of the stuff I was doing might be amenable to using XPath queries to generate my data, so I tested it out based on the simple demos floating around the 'net:
Code:
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = builder.parse("catalog.xml");
XPath xpath = XPathFactory.newInstance.newXPath();
String expression = "/export/widgets[widget/name='foo']";
NodeList widgets = (NodeList) xpath.evaluate(expression, document, XPathConstants.NODESET);
Reading and parsing the file in the first two lines takes about 10-15 seconds. Obviously, this is a one-time read in my current 'architecture.'
Performing the XPath query takes about 30 seconds ... not quite usable in a user-interactive environment.
This is where I am and how I've gotten here. I don't mind refactoring or asking for help or trying to get stuff approved for use; I just don't have the environment in which to (a) properly experiment. I've learned a lot and figured out even more, but I'm coming up on a mental roadblock as to where to proceed from here.
Thanks for your time reading this far...
Any help would be great.