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


Java ProtectionGroupProtectionElement类代码示例

本文整理汇总了Java中gov.nih.nci.security.dao.hibernate.ProtectionGroupProtectionElement的典型用法代码示例。如果您正苦于以下问题:Java ProtectionGroupProtectionElement类的具体用法?Java ProtectionGroupProtectionElement怎么用?Java ProtectionGroupProtectionElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: removeProtectionElementsFromProtectionGroup

import gov.nih.nci.security.dao.hibernate.ProtectionGroupProtectionElement; //导入依赖的package包/类
public void removeProtectionElementsFromProtectionGroup(
		String protectionGroupId, String[] protectionElementIds)
		throws CSTransactionException {
	Session s = null;
	Transaction t = null;
	
	Set pgpes = new HashSet();
	try {
		s = HibernateSessionFactoryHelper.getAuditSession(sf);
		

		ProtectionGroup protectionGroup = (ProtectionGroup) this
				.getObjectByPrimaryKey(s, ProtectionGroup.class, new Long(
						protectionGroupId));

		for (int i = 0; i < protectionElementIds.length; i++) {
			ProtectionGroupProtectionElement intersection = new ProtectionGroupProtectionElement();
			ProtectionElement protectionElement = (ProtectionElement) this
					.getObjectByPrimaryKey(s, ProtectionElement.class,
							new Long(protectionElementIds[i]));

		
			intersection.setProtectionGroup(protectionGroup);
			intersection.setProtectionElement(protectionElement);
			intersection.setUpdateDate(new Date());
			pgpes.add(intersection);
			//this.removeObject(intersection);

		}
		t = s.beginTransaction();
		Iterator iter = pgpes.iterator();
		while(iter.hasNext()){
			this.removeObject((ProtectionGroupProtectionElement)iter.next());
		}

		t.commit();
		s.flush();
		auditLog.info("Deassinging Protection Elements from Protection Group " + protectionGroup.getProtectionGroupName());
	} catch (Exception ex) {
		log.error(ex);
		try {
			t.rollback();
		} catch (Exception ex3) {
			if (log.isDebugEnabled())
				log
						.debug("Authorization|||removeProtectionElementsFromProtectionGroup|Failure|Error in Rolling Back Transaction|"
								+ ex3.getMessage());
		}
		log
				.debug("Authorization|||removeProtectionElementsFromProtectionGroup|Failure|Error Occured in deassigning Protection Elements "
						+ StringUtilities
								.stringArrayToString(protectionElementIds)
						+ " to Protection Group"
						+ protectionGroupId
						+ "|"
						+ ex.getMessage());
		throw new CSTransactionException(
				"An error occured in deassigning Protection Elements from Protection Group\n"
						+ ex.getMessage(), ex);
	} finally {
		try {
			
			s.close();
		} catch (Exception ex2) {
			if (log.isDebugEnabled())
				log
						.debug("Authorization|||removeProtectionElementsFromProtectionGroup|Failure|Error in Closing Session |"
								+ ex2.getMessage());
		}
	}
	log
			.debug("Authorization|||removeProtectionElementsFromProtectionGroup|Success|Success in deassigning Protection Elements "
					+ StringUtilities
							.stringArrayToString(protectionElementIds)
					+ " to Protection Group" + protectionGroupId + "|");
}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:77,代码来源:AuthorizationDAOImpl.java

示例2: removeProtectionElementsFromProtectionGroup

import gov.nih.nci.security.dao.hibernate.ProtectionGroupProtectionElement; //导入依赖的package包/类
public void removeProtectionElementsFromProtectionGroup(
		String protectionGroupId, String[] protectionElementIds)
		throws CSTransactionException {
	Session s = null;
	Transaction t = null;

	try {
		s = sf.openSession();
		t = s.beginTransaction();

		ProtectionGroup protectionGroup = (ProtectionGroup) this
				.getObjectByPrimaryKey(s, ProtectionGroup.class, new Long(
						protectionGroupId));

		for (int i = 0; i < protectionElementIds.length; i++) {
			ProtectionGroupProtectionElement intersection = new ProtectionGroupProtectionElement();

			List list =  s.find("from gov.nih.nci.security.dao.hibernate.ProtectionGroupProtectionElement protectionGroupProtectionElement" +
					" where protectionGroupProtectionElement.protectionElement.protectionElementId="+protectionElementIds[i]+
					" and protectionGroupProtectionElement.protectionGroup.protectionGroupId="+protectionGroupId);
			if(list!=null && list.size()>0)
				this.removeObject(list.get(0));
			
		}
		
		
		
		t.commit();
		

	} catch (Exception ex) {
		log.error(ex);
		try {
			t.rollback();
		} catch (Exception ex3) {
			if (log.isDebugEnabled())
				log
						.debug("Authorization|||removeProtectionElementsFromProtectionGroup|Failure|Error in Rolling Back Transaction|"
								+ ex3.getMessage());
		}
		log
				.debug("Authorization|||removeProtectionElementsFromProtectionGroup|Failure|Error Occured in deassigning Protection Elements "
						+ StringUtilities
								.stringArrayToString(protectionElementIds)
						+ " to Protection Group"
						+ protectionGroupId
						+ "|"
						+ ex.getMessage());
		throw new CSTransactionException(
				"An error occured in deassigning Protection Elements from Protection Group\n"
						+ ex.getMessage(), ex);
	} finally {
		try {
			s.close();
		} catch (Exception ex2) {
			if (log.isDebugEnabled())
				log
						.debug("Authorization|||removeProtectionElementsFromProtectionGroup|Failure|Error in Closing Session |"
								+ ex2.getMessage());
		}
	}
	log
			.debug("Authorization|||removeProtectionElementsFromProtectionGroup|Success|Success in deassigning Protection Elements "
					+ StringUtilities
							.stringArrayToString(protectionElementIds)
					+ " to Protection Group" + protectionGroupId + "|");
}
 
开发者ID:NCIP,项目名称:wustl-common-package,代码行数:68,代码来源:AuthorizationDAOImpl.java


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