Reading the List of Open Networks in Cytoscape - java

I am trying to get a CyNetwork[] containing all of the networks open in the Cytoscape network tab. My understanding is that I need a CyNetworkReader to call CyNetworkReader.getNetworks() and to get a CyNetworkReader I need a CyNetworkReaderManager. However, I don't know how to get a CyNetworkReaderManager, nor do I know the proper InputStream or input name to use CyNetworkReaderManager.getReader(). Any help would be much appreciated.

Close. Actually, you would need a CyNetworkReader to read in a new network from disk. If you want to get the list of currently loaded networks, you would need to use the CyNetworkManager.getNetworkSet() method. To get a handle on the CyNetworkManager, you just need to get it from OSGi, so in your CyActivator, you would do something like:
CyNetworkManager cyNetworkManager = getService(CyNetworkManager.class);
That's it.
-- scooter

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.

capture user asked data from echo

I'm writing a code for Amazon Alexa. And in the developer.amazon.com, we configure the intents, utterances etc... Here I need to get the question asked by the user.
I'm sure that this works using the intents but I will need the utterances. For eg:
GetTheData get me the user data
GetTheData get me user details
Here I'm able to get the GetTheData printed using intent.getName(), But i want to know if there is a way to get the content after the intent name i.e. get me the user data. I want to know this for my research purpose.
Please let me know how can I get this.
Thanks
No, unfortunately there is no way to get this information with the ASK/echo.
Your only solutions at this time would be to split that into one intent per utterance, or switch to google home (its SDK can give you the raw user text).

Arduino-Processing Serial.send/Serial.get interaction

I'm trying to get my Arduino environment to send data to processing for a data visualization project.
I have managed to get the handshake working and can Serial.println(...) to print the data I need from Arduino to the Processing console. What I need now is to somehow use that data to alter a variable within Processing.
I know that neither of the methods that I mention in the title exist within the Serial class but I was hoping someone would know how to manage this functionality.
Thanks in advance!
I will assume that you are using the serialEvent method in processing. Example code:
String val = myPort.readStringUntil('\n');
Where myPort is the port that your android device is on.

How can I check if a specific printer is invoked?

My problem is as follows.
A set of users[lying in the same network and all using windows xp] are using a specific network printer for printing their documents.
Now, whenever someone prints something, I need to check if that file-name starts with a specific code, and if so, I need to insert a row in one of the audit tables.
The problem is, the users can open any document and try to print them using this printer. How can I track that this printer is getting used, when my own piece of code is not invoking it at all?
Is there a way to catch this event of printing on a specific printer, irrespective of any knowledge of the source that fired this event? Is it at all possible to track this using java code?
Waiting eagerly for java gurus to respond. Thanks in advance for your kind co-operation.
Regards,
animark
use some print Server like CUPSD

How should I record `HttpServletRequest`s that are sent to `doPost` in an `HttpServlet` for later playback?

I want to dump some requests (of type javax.servlet.http.HttpServletRequest) into a file and then later replay them from the file, so that I can test future changes to the HttpServlet. What's the best way to accomplish this?
So far, I'm trying to pull data out of the input stream associated with the request, and save this binary data into a file. Ultimately, this may require something like storing a byte-count prior to each saved input stream, so that I know where one request ends and the other begins.
Is there a simpler way to do this?
**EDIT: to clarify, these are not requests involving a browser. So far none of the answers solves my particular problem, which I suppose boils down to serializing and deserializing an HttpServletRequest. I've tried just pulling the bytes from the input stream returned by request.getInputStream(). Unfortunately, if I turn this into a string, it seems that the resulting bytes cannot be parsed by Message.Builder.mergeFrom(bytes).
I'm putting up a bounty for anyone who knows how to solve my problem.
Perhaps you should have a look at Selenium ( http://seleniumhq.org/ ).
I say this because I am presuming that the reason you want to play back the requests is for testing purposes. Selenium records what you do in your browser, and can then play it back.
If you're trying to accomplish something else, perhaps you could explain what you're ultimately trying to do.
There are many local reverse-proxy tools that can 'record-and-playback' a HTTP session. Typically you setup your browser to use a localhost proxy server, perform the actions, save the session, then replay it. JMeter and Charles are two tools that are Java based.
Another option would be to use HttpClient to programmatically exercise your servlet. Using JUnit to execute the tests has an advantage in that it's easier to verify you are getting the 'correct' response.
In my particular case, I eventually solved the problem by using a CodedOutputStream to write the com.google.protobuf.GeneratedMessage (foo below):
ByteArrayOutputStream bos = new ByteArrayOutputStream();
CodedOutputStream cos = CodedOutputStream.newInstance(bos);
foo.writeTo(cos);
This can be read in using a CodedInputStream with something like:
byte[] ba = readBytesFromOutputFile();
CodedInputStream cis = CodedInputStream.newInstance(ba);
The CodedInputStream can then be passed to a message builder to complete the deserialization.

Categories