‎08-07-2015 04:13 PM
Hi,
I have a MegaObject obj from which I can retrieve a property, but not the corresponding attribute
obj.getProp("~Fxk9BUYZI1GA[Fachliche Beschreibung]"); // OK - works obj.getAttribute("~Fxk9BUYZI1GA[Fachliche Beschreibung]"); // => null obj.getAttribute("~Fxk9BUYZI1GA"); // => null obj.getAttribute("Fachliche Beschreibung"); // => null
Any idea/hint how to retrieve the attribute?
Regards
Karl
Solved! Go to Solution.
‎08-10-2015 05:29 PM
Hi Kalina
I asked the service provider who takes care about my MEGA installation to have a look. He found an issue in the MEGA installation and fixed it. Now everything works fine and I can successfully apply code snippets you included in your posts.
Thanks again!
Karl
‎05-10-2015 10:45 AM
Hi Karl,
Maybe you can use the stack trace in the error log and ask the support what is the cause for the error - they should be able to check the code around that exception. I don't have any other ideas.
Best regards,
Kalina
‎02-10-2015 12:29 PM
Hi k6i
thanks for your message!
I tried
System.load("C:/Program Files (x86)/MEGA/System/mg_jnib.dll");
as my first line in the main() method (with a different path to the DLL on my system, though), but no luck.
No luck with registering the mgwmapp.exe either.
Regards
Karl
‎30-09-2015 02:34 PM
Try to see if you have referenced the right mj_api.jar file and that the JRE that you are using is also the Mega one.
Furthermore, try adding the following, on top before everything else:
System.load("C:/Program Files (x86)/MEGA/System/mg_jnib.dll");
Other thing that you might need to do is this, to ensure that the win reg is updated:
"\\ServerName\MEGA\MEGA 2009 SP5\System\mgwmapp.exe" /regserver
‎29-09-2015 03:39 PM
Something must be strange with my installation of MEGA. If I try out the snippet you provided in your previous post there is already problem at the first line:
MegaApplication megaApp = new MegaApplication();
A popup appears "Start nicht möglich. Schlüssel nicht gefunden", in german. In english this is "Failed to launch. Key not found.". Do you know how to tell MEGA via the Java API where to look for the license key?
On the other hand, if I launch MEGA before I run this line, then everything works fine.
Regards
Karl
‎09-09-2015 12:01 PM
Here is the entire code fragment.
If it doesn't work couple of ideas:
1. Double check if it is the right MegaObject and MegaAttribute is imported it should be:
import com.mega.modeling.api.MegaAttribute;
import com.mega.modeling.api.MegaObject;
2. Something wrong with the versions of the jar files - check if the jar files that you use are corresponding to the ones that are in the Mega dir that is executed
3. If you use older version of Mega you will also maybe need to import that file before everything else
System.load("C:/Program Files (x86)/MEGA/System/mg_jnib.dll");
Object[] sort = new String[] { "Short Name" }; MegaApplication megaApp = new MegaApplication(); MegaEnvironment megaEnv = megaApp.getEnvironments().get("Env"); megaEnv.setCurrentAdministrator("User"); megaEnv.setCurrentPassword(""); MegaTransaction transaction = megaEnv.transactions().create("Repository", "User"); MegaRoot megaRoot = transaction.getOwnedDatabase().open(); MegaCollection apps = megaRoot.getSelection("Select [Application] Where [Short Name] like 'S#'", sort); MegaObject temp_app = apps.get(1); System.out.println("apps.size() -> " + apps.size()); System.out.println("temp_app.getID() -> " + temp_app.getID()); MegaAttribute temp_attribute = temp_app.getAttribute("~Z20000000D60[Short Name]"); String temp_app_name = temp_attribute.getValue(); System.out.println(temp_app_name); megaRoot.close(); transaction.getOwnedDatabase().release(); transaction.dispatch(); transaction.release();
‎04-09-2015 02:25 PM
I ran this modified code fragment:
MegaCurrentSession session = new MegaCurrentSession(); MegaRoot root = session.getRoot(""); Object[] sort = new String[] { "Short Name" }; MegaCollection apps = root.getSelection("Select [Application] Where [Short Name] ='SN'", sort); MegaObject temp_app = apps.get(1); System.out.println("apps.size() -> " + apps.size()); System.out.println("temp_app.getID() -> " + temp_app.getID()); MegaAttribute temp_attribute = temp_app.getAttribute("Short Name"); String temp_app_name = temp_attribute.getValue(); System.out.println(temp_app_name);
and the output is
apps.size() -> 1 temp_app.getID() -> 8.3300443203993E-101
‎13-08-2015 10:45 AM
What is the result of apps.size() and temp_app.getID()?
‎16-07-2015 08:50 PM
Thanks for the example! Unfortunately, this very example doesn't work in my environment. The MegaAttribute is always null. That's bizzare
Object[] sort = new String[] { "Short Name" }; MegaCollection apps = root.getSelection("Select [Application] Where [Short Name] ='SN'", sort); MegaObject temp_app = apps.get(1); System.out.println(temp_app); MegaAttribute temp_attribute = temp_app.getAttribute("Short Name"); // temp_attribute is null! String temp_app_name = temp_attribute.getValue(); System.out.println(temp_app_name);
‎16-07-2015 12:40 PM
I made small example for application that works for me
Object[] sort = new String[] { "Short Name" }; MegaCollection apps = megaRoot.getSelection("Select [Application] Where [Application Code] = '"+ application_code + "'", sort); MegaObject temp_app = apps.get(1); String temp_app_name = temp_app.getAttribute("Short Name").getValue(); System.out.println(temp_app_name);