@Override public <T extends InterMineObject> T getObjectByExample(T o, Set<String> fieldNames) throws ObjectStoreException { return osw.getObjectByExample(o, fieldNames); }
@Override public <T extends InterMineObject> T getObjectByExample(T o, Set<String> fieldNames) throws ObjectStoreException { return osw.getObjectByExample(o, fieldNames); }
private UserProfile getUserProfile(String userName) { UserProfile profile = new UserProfile(); profile.setUsername(userName); Set<String> fieldNames = new HashSet<String>(); fieldNames.add("username"); try { profile = osWriter.getObjectByExample(profile, fieldNames); } catch (ObjectStoreException e) { throw new RuntimeException("Unable to load user profile", e); } return profile; }
private UserProfile getUserProfile(String userName) { UserProfile profile = new UserProfile(); profile.setUsername(userName); Set<String> fieldNames = new HashSet<String>(); fieldNames.add("username"); try { profile = osWriter.getObjectByExample(profile, fieldNames); } catch (ObjectStoreException e) { throw new RuntimeException("Unable to load user profile", e); } return profile; }
/** * Perform a query to retrieve a user's backing UserProfile * @param username the username * @return the relevant UserProfile */ public synchronized UserProfile getUserProfile(String username) { UserProfile profile = new UserProfile(); profile.setUsername(username); Set<String> fieldNames = new HashSet<String>(); fieldNames.add("username"); try { profile = uosw.getObjectByExample(profile, fieldNames); } catch (ObjectStoreException e) { throw new RuntimeException("Unable to load user profile", e); } return profile; }
/** * Perform a query to retrieve a user's backing UserProfile * @param username the username * @return the relevant UserProfile */ public synchronized UserProfile getUserProfile(String username) { UserProfile profile = new UserProfile(); profile.setUsername(username); Set<String> fieldNames = new HashSet<String>(); fieldNames.add("username"); try { profile = uosw.getObjectByExample(profile, fieldNames); } catch (ObjectStoreException e) { throw new RuntimeException("Unable to load user profile", e); } return profile; }
private Profile getProfileByApiKey(String token, Map<String, List<FieldDescriptor>> classKeys) { UserProfile profile = new UserProfile(); profile.setApiKey(token); Set<String> fieldNames = new HashSet<String>(); fieldNames.add("apiKey"); try { profile = uosw.getObjectByExample(profile, fieldNames); } catch (ObjectStoreException e) { return null; // Could not be found. } if (profile == null) { throw new AuthenticationException( "'" + token + "' is not a valid API access key"); } return getProfile(profile.getUsername(), classKeys); }
/** * Construct a ProfileManager for the webapp * @param os the ObjectStore to which the webapp is providing an interface * @param userProfileOS the object store that holds user profile information */ public ProfileManager(ObjectStore os, ObjectStoreWriter userProfileOS) { this.os = os; this.uosw = userProfileOS; //retrieve the super user String superUserName = PropertiesUtil.getProperties().getProperty("superuser.account"); UserProfile superuserProfile = new UserProfile(); superuserProfile.setUsername(superUserName); Set<String> fieldNames = new HashSet<String>(); fieldNames.add("username"); try { superuserProfile = uosw.getObjectByExample(superuserProfile, fieldNames); if (superuserProfile != null) { superuser = superuserProfile.getUsername(); } } catch (ObjectStoreException e) { throw new RuntimeException("Unable to load super user profile", e); } pathQueryFormat = loadPathQueryFormatVersion(); permanentTokens.putAll(loadPermanentTokens()); }
private Profile getProfileByApiKey(String token, Map<String, List<FieldDescriptor>> classKeys) { UserProfile profile = new UserProfile(); profile.setApiKey(token); Set<String> fieldNames = new HashSet<String>(); fieldNames.add("apiKey"); try { profile = uosw.getObjectByExample(profile, fieldNames); } catch (ObjectStoreException e) { return null; // Could not be found. } if (profile == null) { throw new AuthenticationException( "'" + token + "' is not a valid API access key"); } return getProfile(profile.getUsername(), classKeys); }
/** * Construct a ProfileManager for the webapp * @param os the ObjectStore to which the webapp is providing an interface * @param userProfileOS the object store that holds user profile information */ public ProfileManager(ObjectStore os, ObjectStoreWriter userProfileOS) { this.os = os; this.uosw = userProfileOS; //retrieve the super user String superUserName = PropertiesUtil.getProperties().getProperty("superuser.account"); UserProfile superuserProfile = new UserProfile(); superuserProfile.setUsername(superUserName); Set<String> fieldNames = new HashSet<String>(); fieldNames.add("username"); try { superuserProfile = uosw.getObjectByExample(superuserProfile, fieldNames); if (superuserProfile != null) { superuser = superuserProfile.getUsername(); } } catch (ObjectStoreException e) { throw new RuntimeException("Unable to load super user profile", e); } pathQueryFormat = loadPathQueryFormatVersion(); permanentTokens.putAll(loadPermanentTokens()); }
public void testSubclassedObject() throws Exception { Manager m1 = new Manager(); m1.setName("m1"); m1.setTitle("Pointy Haired Boss"); Address a1 = new Address(); a1.setAddress("a1"); m1.setAddress(a1); List list = new ArrayList(); list.add(m1); file = File.createTempFile("temp", "xml"); marshalList(list, file); InputStream is = new FileInputStream(file); Source source = iw.getMainSource("testsource", "testsource"); Source skelSource = iw.getSkeletonSource("testsource", "testsource"); loader.processXml(is, source, skelSource); // check address was stored Address a2 = (Address) writer.getObjectByExample(a1, Collections.singleton("address")); assertNotNull("Expected address to be retrieved from DB", a2); assertTrue("address id should be set", (a2.getId().intValue() != 0)); // check company was stored Manager m2 = (Manager) writer.getObjectByExample(m1, Collections.singleton("name")); assertNotNull("Expected company to be retrieved from DB", m2); assertTrue("manager id should be set", (m2.getId().intValue() != 0)); toDelete.add(a2); toDelete.add(m2); } /*