当前位置: 首页>>代码示例>>Java>>正文


Java Group类代码示例

本文整理汇总了Java中org.ndexbio.model.object.Group的典型用法代码示例。如果您正苦于以下问题:Java Group类的具体用法?Java Group怎么用?Java Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Group类属于org.ndexbio.model.object包,在下文中一共展示了Group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test0001CreateGroup

import org.ndexbio.model.object.Group; //导入依赖的package包/类
/**
 * Create a group on the server, and delete it.
 * 
 * APIs tested: public Group createGroup(Group)
 *              public Group getGroup(String)
 */
@Test
public void test0001CreateGroup() {

	// create new group
	newGroup = GroupUtils.createGroup(ndex, group);
	
	// check the contents of the newly created  Group object
	GroupUtils.compareGroupObjectsContents(group, newGroup);
	
	// now, get the newly created group using getGroup API
	UUID groupId = newGroup.getExternalId();
	Group createdGroup = GroupUtils.getGroup(ndex, groupId);
	
	// check the contents of the newly created  Group object
	GroupUtils.compareGroupObjectsContents(group, createdGroup);
}
 
开发者ID:ndexbio,项目名称:ndex-java-client,代码行数:23,代码来源:testGroupService.java

示例2: test0003CreateGroupWithInvalidName

import org.ndexbio.model.object.Group; //导入依赖的package包/类
/**
 * Try to create a group with the same name as user/account name. 
 * DuplicateObjectException is expected.
 * 
 * APIs tested: public Group createGroup(Group)
 *            
 */
@Test
public void test0003CreateGroupWithInvalidName() throws JsonProcessingException, IOException, NdexException {
	
	newGroup = new Group();

	// set the group name to be user/account name
	newGroup.setGroupName(accountName);
	
	// initialize other properties
	newGroup.setDescription(group.getDescription());
	newGroup.setImage(group.getImage());
	newGroup.setGroupName(group.getGroupName());
	newGroup.setWebsite(group.getWebsite());
	
	// expected exception is DuplicateObjectException
    thrown.expect(DuplicateObjectException.class);

	// expected message of DuplicateObjectException
    thrown.expectMessage("Group with name " + accountName.toLowerCase() + " already exists.");
    
	// try to create new group with the same name as user/account
    // exception is expected
	ndex.createGroup(newGroup);
}
 
开发者ID:ndexbio,项目名称:ndex-java-client,代码行数:32,代码来源:testGroupService.java

示例3: getGroupsByUUIDs

import org.ndexbio.model.object.Group; //导入依赖的package包/类
@SuppressWarnings("static-method")
@POST
@PermitAll
@AuthenticationNotRequired
@Path("/group")
@Produces("application/json")
@ApiDoc("Returns a list of groups for the groups specified by the groupid list. Errors if any of the group id is not found. ")
public List<Group> getGroupsByUUIDs(List<String> groupIdStrs)
		throws IllegalArgumentException,ObjectNotFoundException, NdexException, JsonParseException, JsonMappingException, SQLException, IOException {
	
	if ( groupIdStrs == null )
		throw new ForbiddenOperationException("A group id list is required.");
	
	accLogger.info("[data]\t[uuidcounts:" +groupIdStrs.size() + "]" );

	try (GroupDAO dao = new GroupDAO()) {
		List<Group> groups = new LinkedList<>();
		for ( String groupId : groupIdStrs) {
		  final Group group = dao.getGroupById(UUID.fromString(groupId));
		  groups.add(group);
		}
		return groups;
	} 
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:25,代码来源:BatchServiceV2.java

示例4: createGroup

import org.ndexbio.model.object.Group; //导入依赖的package包/类
/**************************************************************************
 * Creates a group.
 * 
 * @param newGroup
 *            The group to create.
 * @return The newly created group.
 * @throws Exception 
 **************************************************************************/
/*
 * refactor this method to use non-transactional database interactions
 * validate input data before creating a database vertex
 */
@POST
@Produces("application/json")
@ApiDoc("Create a group owned by the authenticated user based on the supplied group JSON structure. " +
        "Errors if the group name specified in the JSON is not valid or is already in use. ")
public Group createGroup(final Group newGroup)
		throws Exception {

	try (GroupDAO dao = new GroupDAO()){
	//	newGroup.setGroupName(newGroup.getGroupName().toLowerCase());
		Group group = dao.createNewGroup(newGroup, this.getLoggedInUser().getExternalId());
		try (GroupIndexManager m = new GroupIndexManager()) {
			m.addGroup(group.getExternalId().toString(), group.getGroupName(), group.getDescription());
		}
		dao.commit();	
		return group;
	} 
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:30,代码来源:GroupService.java

示例5: getGroupsByUUIDs

import org.ndexbio.model.object.Group; //导入依赖的package包/类
@POST
@PermitAll
@Path("/groups")
@Produces("application/json")
@ApiDoc("Returns a group JSON structure for the group specified by groupId. Errors if the group is not found. ")
public List<Group> getGroupsByUUIDs(List<String> groupIdStrs)
		throws IllegalArgumentException,ObjectNotFoundException, NdexException, JsonParseException, JsonMappingException, SQLException, IOException {
	
	try (GroupDAO dao = new GroupDAO()) {
		List<Group> groups = new LinkedList<>();
		for ( String groupId : groupIdStrs) {
		  final Group group = dao.getGroupById(UUID.fromString(groupId));
		  groups.add(group);
		}
		return groups;
	} 
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:18,代码来源:GroupService.java

示例6: getGroup

import org.ndexbio.model.object.Group; //导入依赖的package包/类
/**************************************************************************
 * Gets a group by ID or name.
 * 
 * @param groupId
 *            The ID or name of the group.
 * @throws IllegalArgumentException
 *             Bad input.
 * @throws NdexException
 *             Failed to query the database.
 * @return The group.

 **************************************************************************/
@GET
@PermitAll
@Path("/{groupid}")
@Produces("application/json")
@ApiDoc("Returns a group JSON structure for the group specified by groupId. Errors if the group is not found. ")
public Group getGroup(@PathParam("groupid") final String groupId)
		throws ObjectNotFoundException, NdexException, SQLException {
	
	try (GroupDAO dao = new GroupDAO()) {
		final Group group = dao.getGroupById(UUID.fromString(groupId));
		return group;
	} catch (IOException e) {
		throw new NdexException("Failed to get group: " + e.getMessage(), e);
	} 
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:28,代码来源:GroupServiceV2.java

示例7: findGroups

import org.ndexbio.model.object.Group; //导入依赖的package包/类
/**************************************************************************
 * Find Groups based on search parameters - string matching for now
 * 
 * @params searchParameters The search parameters.
 * @return Groups that match the search criteria.
 * @throws Exception 
 **************************************************************************/
@POST
@PermitAll
@AuthenticationNotRequired
@Path("/group")
@Produces("application/json")
@ApiDoc("Returns a list of groups found based on the searchOperator and the POSTed searchParameters.")
public SolrSearchResult<Group> findGroups(SimpleQuery simpleQuery,
		@DefaultValue("0") @QueryParam("start") int skipBlocks,
		@DefaultValue("100") @QueryParam("size") int blockSize)
		throws Exception {

//	logger.info("[start: Search group \"{}\"]", simpleQuery.getSearchString());
	accLogger.info("[data]\t[query:" +simpleQuery.getSearchString() + "]" );

	try (GroupDAO dao = new GroupDAO()) {
		final SolrSearchResult<Group> groups = dao.findGroups(simpleQuery, skipBlocks, blockSize);
//		logger.info("[end: Search group \"{}\"]", simpleQuery.getSearchString());
		return groups;
	} 
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:28,代码来源:SearchServiceV2.java

示例8: getGroupById

import org.ndexbio.model.object.Group; //导入依赖的package包/类
/**************************************************************************
    * Get a Group
    * 
    * @param id
    *            UUID for Group
    * @throws NdexException
    *            Attempting to access database
    * @throws IllegalArgumentexception
    * 			The id is invalid
    * @throws ObjectNotFoundException
    * 			The group specified by id does not exist
 * @throws SQLException 
 * @throws IOException 
 * @throws JsonMappingException 
 * @throws JsonParseException 
    **************************************************************************/
public Group getGroupById(UUID id)
		throws ObjectNotFoundException, NdexException, SQLException, JsonParseException, JsonMappingException, IOException{
	Preconditions.checkArgument(null != id, 
			"UUID required");
	
	String sqlStr = "SELECT * FROM " + NdexClasses.Group + " where \"UUID\" = '" + id + "' :: uuid and is_deleted = false";

	try (Statement st = db.createStatement()) {
		try (ResultSet rs = st.executeQuery(sqlStr) ) {
			if (rs.next()) {
				// populate the user object;
				Group result = new Group();

				populateGroupFromResultSet(result, rs);

				return result;
			} 
			throw new ObjectNotFoundException("Group with UUID: " + id.toString() + " doesn't exist.");

		}
	}
	
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:40,代码来源:GroupDAO.java

示例9: getGroupByGroupName

import org.ndexbio.model.object.Group; //导入依赖的package包/类
/**************************************************************************
    * Get a Group
    * 
    * @param accountName
    *            Group's accountName
    * @throws NdexException
    *            Attempting to access database
    * @throws IllegalArgumentexception
    * 
    * 			The id is invalid
    * @throws ObjectNotFoundException
    * 			The group specified by id does not exist
 * @throws SQLException 
 * @throws IOException 
 * @throws JsonMappingException 
 * @throws JsonParseException 
    **************************************************************************/
public Group getGroupByGroupName(String accountName)
		throws IllegalArgumentException, ObjectNotFoundException, NdexException, SQLException, JsonParseException, JsonMappingException, IOException{
	Preconditions.checkArgument(!Strings.isNullOrEmpty(accountName), 
			"UUID required");
	
	String sqlStr = "SELECT * FROM " + NdexClasses.Group + " where group_name = ? and is_deleted = false";

	try (PreparedStatement st = db.prepareStatement(sqlStr)) {
		st.setString(1, accountName);
		try (ResultSet rs = st.executeQuery() ) {
			if (rs.next()) {
				// populate the user object;
				Group result = new Group();

				populateGroupFromResultSet(result, rs);

				return result;
			} 
			throw new ObjectNotFoundException("Group " + accountName + " doesn't exist.");

		}
	}

}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:42,代码来源:GroupDAO.java

示例10: findGroups

import org.ndexbio.model.object.Group; //导入依赖的package包/类
/**************************************************************************
    * Find groups
    * 
    * @param query
    * 			SimpleUserQuery object. The search string filters by 
    * 			group account name and organization name. The accountName
    * 			filters to groups owned by the account specified.
    * @param skipBlocks
    *            amount of blocks to skip
    * @param blockSize
    * 			the size of a block
 * @throws Exception 
    **************************************************************************/
public SolrSearchResult<Group> findGroups(SimpleQuery simpleQuery, int skipBlocks, int blockSize) 
		throws Exception {
	
	Preconditions.checkArgument(null != simpleQuery, "Search parameters are required");

	 if ( simpleQuery.getSearchString().length()==0)
	    	simpleQuery.setSearchString("*:*");
	 
	try (GroupIndexManager indexManager = new GroupIndexManager()) {
		SolrDocumentList l = indexManager.searchGroups(simpleQuery.getSearchString(), blockSize,
				skipBlocks * blockSize);
		List<Group> results = new ArrayList<>(l.size());
		for (SolrDocument d : l) {
			results.add(getGroupById(UUID.fromString((String) d.get(GroupIndexManager.UUID))));
		}

		return new SolrSearchResult<>(l.getNumFound(), l.getStart(), results);
	}
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:33,代码来源:GroupDAO.java

示例11: checkForExistingGroup

import org.ndexbio.model.object.Group; //导入依赖的package包/类
private void checkForExistingGroup(final Group group) 
		throws IllegalArgumentException, NdexException, JsonParseException, JsonMappingException, SQLException, IOException {
	
	Preconditions.checkArgument(null != group, 
			"UUID required");

	try {
		getGroupByGroupName(group.getGroupName());
		String msg = "Group with name " + group.getGroupName() + " already exists.";
		logger.info(msg);
		throw new DuplicateObjectException(msg);
	} catch ( ObjectNotFoundException e) {
		// when account doesn't exists return as normal.
	}
	
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:17,代码来源:GroupDAO.java

示例12: getGroupFromDocument

import org.ndexbio.model.object.Group; //导入依赖的package包/类
public static Group getGroupFromDocument(ODocument n) {
	
	Group result = new Group();

	Helper.populateExternalObjectFromDoc (result, n);

	result.setGroupName((String)n.field(NdexClasses.GRP_P_NAME));
	result.setWebsite((String)n.field("websiteURL"));
	result.setDescription((String)n.field("description"));
	result.setImage((String)n.field("imageURL"));
	if ( result.getIsDeleted()) {
		result.setAccountName((String)n.field(NdexClasses.account_P_oldAcctName));	
	} else {
	  result.setAccountName((String)n.field(NdexClasses.account_P_accountName));
	}
	return result;
}
 
开发者ID:ndexbio,项目名称:ndex-common,代码行数:18,代码来源:GroupDocDAO.java

示例13: checkForExistingGroup

import org.ndexbio.model.object.Group; //导入依赖的package包/类
private void checkForExistingGroup(final Group group) 
		throws IllegalArgumentException, NdexException {
	
	Preconditions.checkArgument(null != group, 
			"UUID required");

	try {
		getRecordByAccountName(group.getAccountName(), null);
		String msg = "Group with name " + group.getAccountName() + " already exists.";
		logger.info(msg);
		throw new DuplicateObjectException(msg);
	} catch ( ObjectNotFoundException e) {
		// when account doesn't exists return as normal.
	}
	
}
 
开发者ID:ndexbio,项目名称:ndex-common,代码行数:17,代码来源:GroupDAO.java

示例14: createGroup

import org.ndexbio.model.object.Group; //导入依赖的package包/类
@Test
public void createGroup() {
	
	try {
		localConnection.begin();
		final Group newGroup = new Group();
           newGroup.setGroupName("create");
           newGroup.setAccountName("create");
           newGroup.setDescription("create");
           newGroup.setWebsite("create");
           
           assertNotNull(dao.createNewGroup(newGroup, testUser.getExternalId()));
           localConnection.rollback();
          
	} catch (Throwable e){
		
		fail(e.getMessage());
		
	}
	
}
 
开发者ID:ndexbio,项目名称:ndex-common,代码行数:22,代码来源:TestGroupDAO.java

示例15: createTestGroup

import org.ndexbio.model.object.Group; //导入依赖的package包/类
private void createTestGroup() {
	
	try {
		
		final Group newGroup = new Group();
           newGroup.setGroupName("testGroup");
           newGroup.setAccountName("testGroup");
           newGroup.setDescription("testGroup");
           newGroup.setWebsite("testGroup");
		
        testGroup = dao.createNewGroup(newGroup, testUser.getExternalId());
        localConnection.commit();
       
       	//return true;
       	
	} catch (Exception e) {
		//System.out.println(e.getMessage());
		fail(e.getMessage());
		
	}
}
 
开发者ID:ndexbio,项目名称:ndex-common,代码行数:22,代码来源:TestGroupDAO.java


注:本文中的org.ndexbio.model.object.Group类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。