Saving and loading iCalendar event data in a separate file - java

I am creating a program which can manage project schedule using iCalendar. I need to be able to save all the information used in creating a VEvent in some type of data holder and then output it in a file, which after can be loaded and data might be edited or more data added. I think JTable is kind of suitable for my needs, one row will represent one VEvent and columns will have different information. But if anyone has a better suggestion, I want to hear it.
My question is, what is the best data holder for this type of information and how to save that data to a file and load it afterwards.

You can for sure use the iCalendar file format as defined in RFC5545 and only have one VEVENT in your calendar and have a file per event but you could equally store them in a database and leverage this SOical-field-list-for-database-schema-based-on-ical-standard

VEvent seems like a good idea since it´s easy to export to this format for your custumers.

Related

Saving data to file or database

I'm starting to work on a new Java desktop app that should help me and my colleagues learn vocabulary. It will contain around 700 words, some texts (that point to the words contained in them) and maybe some images (not sure about that part yet). The data will never change and I want the program to be able to run offline.
The question is: Should I use database, text file or serialize the data into file? Or perhaps if there is any other option I don't know about? If you could explain your choice in detail I would be glad.
If the data never changes and is only 700 words it would probably be easiest to use a file.
If your data was a bit more complex and had many fields and was being constantly updated, a database would be more preferable but a csv file could still be used.
Since you want to access this data offline and data never changes, I think the best option would be to just use text file, which will be more efficient in terms of access and speed.
Keep all the data in memory as Serializable Java objects, and store them serialized when your application is not running. Evaluate airomem - really nice solution that would perfectly work for you.

Java framework to manage BLOB data outside of database

I want to store my blobs outside of the database in files, however they are just random blobs of data and aren't directly linked to a file.
So for example I have a table called Data with the following columns:
id
name
comments
...
I can't just include a column called fileLink or something like that because the blob is just raw data. I do however want to store it outside of the database. I would love to create a file called 3.dat where 3 is the id number for that row entry. The only thing with this setup is that the main folder will quickly start to have a large number of files as the id is a flat folder structure and there will be OS file issues. And no the data is not grouped or structured, it's one massive list.
Is there a Java framework or library that will allow me to store and manage the blobs so that I can just do something like MyBlobAPI.saveBlob(id, data); and then do MyBlobAPI.getBlob(id) and so on? In other words something where all the File IO is handled for me?
Simply use an appropriate database which implements blobs as you described, and use JDBC. You really are not looking for another API but a specific implementation. It's up to the DB to take care of effective storing of blobs.
I think a home rolled solution will include something like a fileLink column in your table and your api will create files on the first save and then write that file on update.
I don't know of any code base that will do this for you. There are a bunch that provide an in memory file system for java. But it's only a few lines of code to write something that writes and reads java objects to a file.
You'll have to handle any file system limitations yourself. Though I doubt you'll ever burn through the limitations of modern file systems like btrfs or zfs. FAT32 is limited to 65K files per directory. But even last generation file systems support something on the order of 4 billion files per directory.
So by all means, write a class with two functions. One to serialize an object to a file; given it a unique key as a name. And another to deserialize the object by that key. If you are using a modern file system, you'll never run out of resources.
As far as I can tell there is no framework for this. The closest I could find was Hadoop's HDFS.
That being said the advice of just putting the BLOB's into the database as per the answers below is not always advisable. Sometimes it's good and sometimes it's not, it really depends on your situation. Here are a few links to such discussions:
Storing Images in DB - Yea or Nay?
https://softwareengineering.stackexchange.com/questions/150669/is-it-a-bad-practice-to-store-large-files-10-mb-in-a-database
I did find some addition really good links but I can't remember them offhand. There was one in particular on StackOverFlow but I can't find it. If you believe you know the link please add it in the comments so that I can confirm it's the right one.

Making a shapefile editor with in geotools jmappane

What would be involved in creating a shapefile editor with begin, save and and end editing for points, lines and polygons in jmappane for geotools?
I know how to update, delete and add to shapefiles with geotools with transactions, but I am not sure how I would display the updated data before actually having the data updated via the save option or even how to display your own data in jmappane.
Thanks in advance
You need to have some interface to allow loading the data and showing them.
Do you mean to visually edit a map representation of the data, some kind of tabular/spreadsheet version of the data or some kind of online query generator? Depending on what you want the options are very different.
You will need to have some way to export your results to a format the user can download.
Check out MapShaper as a starting point.
This is perfectly possible, one option for you to study is UDig which is a full GIS system built using GeoTools. If that is too complex for you then you could look at my ShapefileViewer which shows how you load and display a shapefile but doesn't include any editing functionality.

Plausibility of plan to use DOM4J with JTables & Action Listeners

I am preparing to embark on a large solo project at my place of employment. First let me describe the project. I have been asked to create a Java program that can take a CamT54 file (which is just a xml file) and have java display the information in table form. Then users should be given the ability to remove certain components from the table and have it go back to xml format with the changes.
I'm not well versed in dealing with XML in Java so this is going to be a learn and work task. Before I begin investing time I would like to know that my approach is the best approach.
My plan is to use DOM4J to do the parsing and handling of the xml. I will use a JTable to display the data and incorporate some buttons to the GUI that allow the modifications of the data through the use of some action listeners.
Would this be a plausible plan? Can DOM4J effectively allow xml data to be displayed in a table format and furthermore could that data be easily modified or deleted then resaved to a new xml?
I thought I would go ahead and answer this as I finished the program and wanted to post what I thought was the easiest solution in case anyone else needed help.
It turned out the easiest approach (for me at least) was to use the standard DOM parser, here are the steps I took.
Parsed the entire XML into String array lists. XPath was required for this, I also had to convert the elements into Strings and remove the extra tag information from the string using substrings since I only wanted the actual value.
I populated a JTable with these arrays.
Once users finished editing and clicked a save button then another Dom parser would take the original XML and change each and every attribute using the values from the Arrays (that were deleted and repopulated with the JTable cell values when the user clicked "save").

Saving More Complicated Application Data

For simple program data that needed to be saved I just used properties files before but I was wondering how I can save more complicated application data such as: arraylists e.g..
How would I save such data into a file? And is there a way to save it in a file with my own extension ( so not .properties for example when using the properties method to save data ) and to make sure it cannot be edited by user manually ( which is simply possible with notepad for example for .properties files )?
Thanks in advance.
Best Regards,
Skyfe.
Serialize to XML, encode/encrypt the data prior to persisting, and then decode/decrypt the data when consuming from your app.
The simplest way to do this as stated is to use the built-in Serialization mechanism. Just serialize your ArrayList out to a file using an ObjectOutputStream wrapped around a FileOutputStream. As long as each item in your list is serializable, this will work fine.
It's not impossible to modify, but it's fairly obfuscated over, say, a text file (it's binary for starters).
You can use a self contained database like SQLite

Categories