Java Code Examples for org.apache.commons.collections4.set.ListOrderedSet#addAll()

The following examples show how to use org.apache.commons.collections4.set.ListOrderedSet#addAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
public List<String> listSupNestedWithPerson(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<>();
	List<String> list = new ArrayList<>();
	for (String o : this.listSupDirectWithPerson(id)) {
		if (!set.contains(o)) {
			list.add(o);
		}
	}
	if (!list.isEmpty()) {
		set.addAll(list);
		for (String str : list) {
			this.supNested(str, set);
		}
	}
	return set.asList();
}
 
Example 2
Source File: ListTools.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T> List<T> subtractWithProperty(Object obj, String propertyName, List<T> ts) throws Exception {
	List<T> list = new ArrayList<>();
	ListOrderedSet<T> set = new ListOrderedSet<T>();
	Object o = PropertyUtils.getProperty(obj, propertyName);
	if (null != o) {
		set.addAll((List<T>) o);
	}
	if (null != ts) {
		for (T t : ts) {
			if (set.contains(t)) {
				set.remove(t);
				list.add(t);
			}
		}
	}
	PropertyUtils.setProperty(obj, propertyName, set.asList());
	return list;
}
 
Example 3
Source File: ListTools.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T> List<T> subtractWithProperty(Object obj, String propertyName, T... ts) throws Exception {
	List<T> list = new ArrayList<>();
	ListOrderedSet<T> set = new ListOrderedSet<T>();
	Object o = PropertyUtils.getProperty(obj, propertyName);
	if (null != o) {
		set.addAll((List<T>) o);
	}
	for (T t : ts) {
		if (set.contains(t)) {
			set.remove(t);
			list.add(t);
		}
	}
	PropertyUtils.setProperty(obj, propertyName, set.asList());
	return list;
}
 
Example 4
Source File: ListTools.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T> List<T> addWithProperty(Object obj, String propertyName, boolean ignoreNull, List<T> ts)
		throws Exception {
	List<T> list = new ArrayList<>();
	ListOrderedSet<T> set = new ListOrderedSet<T>();
	Object o = PropertyUtils.getProperty(obj, propertyName);
	if (null != o) {
		set.addAll((List<T>) o);
	}
	if (null != ts) {
		for (T t : ts) {
			if (null == t && ignoreNull) {
				continue;
			}
			if (!set.contains(t)) {
				set.add(t);
				list.add(t);
			}
		}
	}
	PropertyUtils.setProperty(obj, propertyName, set.asList());
	return list;
}
 
Example 5
Source File: ListTools.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T> List<T> addWithProperty(Object obj, String propertyName, boolean ignoreNull, T... ts)
		throws Exception {
	List<T> list = new ArrayList<>();
	ListOrderedSet<T> set = new ListOrderedSet<T>();
	Object o = PropertyUtils.getProperty(obj, propertyName);
	if (null != o) {
		set.addAll((List<T>) o);
	}
	for (T t : ts) {
		if (null == t && ignoreNull) {
			continue;
		}
		if (!set.contains(t)) {
			set.add(t);
			list.add(t);
		}
	}
	PropertyUtils.setProperty(obj, propertyName, set.asList());
	return list;
}
 
Example 6
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
public List<String> listSupNestedWithPerson(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<>();
	List<String> list = new ArrayList<>();
	for (String o : this.listSupDirectWithPerson(id)) {
		if (!set.contains(o)) {
			list.add(o);
		}
	}
	if (!list.isEmpty()) {
		set.addAll(list);
		for (String str : list) {
			this.supNested(str, set);
		}
	}
	return set.asList();
}
 
Example 7
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
public List<String> listSupNestedWithPerson(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<>();
	List<String> list = new ArrayList<>();
	for (String o : this.listSupDirectWithPerson(id)) {
		if (!set.contains(o)) {
			list.add(o);
		}
	}
	if (!list.isEmpty()) {
		set.addAll(list);
		for (String str : list) {
			this.supNested(str, set);
		}
	}
	return set.asList();
}
 
Example 8
Source File: GroupFactory.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
public List<String> listSupNestedWithPerson(String id) throws Exception {
	ListOrderedSet<String> set = new ListOrderedSet<>();
	List<String> list = new ArrayList<>();
	for (String o : this.listSupDirectWithPerson(id)) {
		if (!set.contains(o)) {
			list.add(o);
		}
	}
	if (!list.isEmpty()) {
		set.addAll(list);
		for (String str : list) {
			this.supNested(str, set);
		}
	}
	return set.asList();
}
 
Example 9
Source File: AbstractLabel.java    From sqlg with MIT License 5 votes vote down vote up
public ListOrderedSet<String> getIdentifiers() {
    ListOrderedSet<String> result = ListOrderedSet.listOrderedSet(this.identifiers);
    if (this.getSchema().getTopology().isSqlWriteLockHeldByCurrentThread()) {
        result.addAll(this.uncommittedIdentifiers);
    }
    return result;
}
 
Example 10
Source File: IterativeFindPathsAlgorithm.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void unblock(V v) {

		ListOrderedSet<V> toProcess = new ListOrderedSet<>();
		toProcess.add(v);

		while (!toProcess.isEmpty()) {
			V next = toProcess.remove(0);
			Set<V> childBlocked = doUnblock(next);
			if (childBlocked != null && !childBlocked.isEmpty()) {
				toProcess.addAll(childBlocked);
				childBlocked.clear();
			}
		}
	}
 
Example 11
Source File: ActionDelete.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		ActionResult<Wo> result = new ActionResult<>();
		Business business = new Business(emc);
		Share share = emc.find(id, Share.class);
		if (null == share) {
			throw new ExceptionAttachmentNotExist(id);
		}
		/* 判断文件的所有者是否是当前用户 */
		if (!StringUtils.equals(effectivePerson.getDistinguishedName(), share.getPerson())) {
			throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
		}
		EntityManager em = emc.beginTransaction(Share.class);
		emc.delete(Share.class, share.getId());
		em.getTransaction().commit();
		if(!"password".equals(share.getShareType())){
			List<String> shareCancels = new ArrayList<>();
			shareCancels.addAll(share.getShareUserList());
			if(!share.getShareOrgList().isEmpty()){
				shareCancels.addAll(business.organization().person().listWithUnitSubNested( share.getShareOrgList() ));
			}
			ListOrderedSet<String> set = new ListOrderedSet<>();
			set.addAll(shareCancels);
			shareCancels = set.asList();
			/* 发送取消共享通知 */
			for (String str : shareCancels) {
				this.message_send_attachment_shareCancel(share, str);
			}
		}
		Wo wo = new Wo();
		wo.setValue(true);
		result.setData(wo);
		return result;
	}
}
 
Example 12
Source File: FolderFactory.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public List<String> listSubNested(String id) throws Exception {
	ListOrderedSet<String> list = new ListOrderedSet<>();
	List<String> subs = this.listSubDirect(id);
	for (String str : subs) {
		if (!list.contains(str)) {
			list.add(str);
			list.addAll(this.listSubNested(str));
		}
	}
	return list.asList();
}
 
Example 13
Source File: Folder2Factory.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public List<String> listSubNested(String id, String status) throws Exception {
	ListOrderedSet<String> list = new ListOrderedSet<>();
	List<String> subs = this.listSubDirect(id, status);
	for (String str : subs) {
		if (!list.contains(str)) {
			list.add(str);
			list.addAll(this.listSubNested(str, status));
		}
	}
	return list.asList();
}
 
Example 14
Source File: ActionDelete.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		ActionResult<Wo> result = new ActionResult<>();
		Business business = new Business(emc);
		Share share = emc.find(id, Share.class);
		if (null == share) {
			throw new ExceptionAttachmentNotExist(id);
		}
		/* 判断文件的所有者是否是当前用户 */
		if (!StringUtils.equals(effectivePerson.getDistinguishedName(), share.getPerson())) {
			throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
		}
		EntityManager em = emc.beginTransaction(Share.class);
		emc.delete(Share.class, share.getId());
		em.getTransaction().commit();
		if(!"password".equals(share.getShareType())){
			List<String> shareCancels = new ArrayList<>();
			shareCancels.addAll(share.getShareUserList());
			if(!share.getShareOrgList().isEmpty()){
				shareCancels.addAll(business.organization().person().listWithUnitSubNested( share.getShareOrgList() ));
			}
			ListOrderedSet<String> set = new ListOrderedSet<>();
			set.addAll(shareCancels);
			shareCancels = set.asList();
			/* 发送取消共享通知 */
			for (String str : shareCancels) {
				this.message_send_attachment_shareCancel(share, str);
			}
		}
		Wo wo = new Wo();
		wo.setValue(true);
		result.setData(wo);
		return result;
	}
}
 
Example 15
Source File: FolderFactory.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public List<String> listSubNested(String id) throws Exception {
	ListOrderedSet<String> list = new ListOrderedSet<>();
	List<String> subs = this.listSubDirect(id);
	for (String str : subs) {
		if (!list.contains(str)) {
			list.add(str);
			list.addAll(this.listSubNested(str));
		}
	}
	return list.asList();
}
 
Example 16
Source File: Folder2Factory.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public List<String> listSubNested(String id, String status) throws Exception {
	ListOrderedSet<String> list = new ListOrderedSet<>();
	List<String> subs = this.listSubDirect(id, status);
	for (String str : subs) {
		if (!list.contains(str)) {
			list.add(str);
			list.addAll(this.listSubNested(str, status));
		}
	}
	return list.asList();
}
 
Example 17
Source File: ActionCreate.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		ActionResult<Wo> result = new ActionResult<>();
		Business business = new Business(emc);
		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
		if (StringUtils.isEmpty(wi.getFileId())) {
			throw new ExceptionShareNameEmpty();
		}
		if (StringUtils.isEmpty(wi.getShareType())) {
			throw new Exception("shareType can not be empty.");
		}
		Share share = business.share().getShareByFileId(wi.getFileId(),effectivePerson.getDistinguishedName());
		boolean isExist = true;
		List<String> oldUserList = new ArrayList<>();
		List<String> oldOrgList = new ArrayList<>();
		if(share == null) {
			share = Wi.copier.copy(wi);
			isExist = false;
		}else{
			oldUserList.addAll(share.getShareUserList());
			oldOrgList.addAll(share.getShareOrgList());
			share.setPassword(wi.getPassword());
			share.setShareUserList(wi.getShareUserList());
			share.setShareOrgList(wi.getShareOrgList());
			share.setShareType(wi.getShareType());
		}
		if("password".equals(wi.getShareType())){
			if(StringUtils.isBlank(share.getPassword())){
				throw new Exception("password can not be empty.");
			}
		}else{
			if((wi.getShareUserList()==null || wi.getShareUserList().isEmpty()) &&
					(wi.getShareOrgList()==null || wi.getShareOrgList().isEmpty())){
				throw new Exception("shareUserList or shareOrgList can not be empty.");
			}
		}
		Attachment2 attachment = emc.find(wi.getFileId(), Attachment2.class);
		if(attachment == null) {
			Folder2 folder = emc.find(wi.getFileId(), Folder2.class);
			if(folder==null){
				throw new ExceptionShareNotExist(wi.getFileId());
			}else{
				if (!effectivePerson.isManager() && !StringUtils.equals(folder.getPerson(), effectivePerson.getDistinguishedName())) {
					throw new Exception("person{name:" + effectivePerson.getDistinguishedName() + "} access folder{id:" + wi.getFileId()
							+ "} denied.");
				}
				share.setFileType("folder");
				share.setName(folder.getName());
				share.setPerson(folder.getPerson());
			}
		}else{
			if (!effectivePerson.isManager() && !StringUtils.equals(attachment.getPerson(), effectivePerson.getDistinguishedName())) {
				throw new Exception("person{name:" + effectivePerson.getDistinguishedName() + "} access att{id:" + wi.getFileId()
						+ "} denied.");
			}
			share.setFileType("attachment");
			share.setName(attachment.getName());
			share.setLength(attachment.getLength());
			share.setExtension(attachment.getExtension());
			share.setPerson(attachment.getPerson());
		}
		share.setLastUpdateTime(new Date());
		if(share.getValidTime()==null){
			share.setValidTime(DateTools.getDateAfterYearAdjust(new Date(),100,null,null));
		}

		emc.beginTransaction(Share.class);
		if(isExist){
			emc.check(share, CheckPersistType.all);
		}else {
			emc.persist(share, CheckPersistType.all);
		}
		emc.commit();
		if(!"password".equals(wi.getShareType())){
			if(!oldOrgList.isEmpty()){
				oldUserList.addAll(business.organization().person().listWithUnitSubNested( oldOrgList ));
			}
			List<String> newUserList = new ArrayList<>();
			newUserList.addAll(share.getShareUserList());
			if(!share.getShareOrgList().isEmpty()){
				newUserList.addAll(business.organization().person().listWithUnitSubNested( share.getShareOrgList() ));
			}
			List<String> shareAdds = ListUtils.subtract(newUserList, oldOrgList);
			ListOrderedSet<String> set = new ListOrderedSet<>();
			set.addAll(shareAdds);
			shareAdds = set.asList();
			/* 发送共享通知 */
			for (String str : shareAdds) {
				this.message_send_attachment_share(share, str);
			}
		}
		Wo wo = new Wo();
		wo.setId(share.getId());
		result.setData(wo);
		return result;
	}
}
 
Example 18
Source File: ActionCreate.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		ActionResult<Wo> result = new ActionResult<>();
		Business business = new Business(emc);
		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
		if (StringUtils.isEmpty(wi.getFileId())) {
			throw new ExceptionShareNameEmpty();
		}
		if (StringUtils.isEmpty(wi.getShareType())) {
			throw new Exception("shareType can not be empty.");
		}
		Share share = business.share().getShareByFileId(wi.getFileId(),effectivePerson.getDistinguishedName());
		boolean isExist = true;
		List<String> oldUserList = new ArrayList<>();
		List<String> oldOrgList = new ArrayList<>();
		if(share == null) {
			share = Wi.copier.copy(wi);
			isExist = false;
		}else{
			oldUserList.addAll(share.getShareUserList());
			oldOrgList.addAll(share.getShareOrgList());
			share.setPassword(wi.getPassword());
			share.setShareUserList(wi.getShareUserList());
			share.setShareOrgList(wi.getShareOrgList());
			share.setShareType(wi.getShareType());
		}
		if("password".equals(wi.getShareType())){
			if(StringUtils.isBlank(share.getPassword())){
				throw new Exception("password can not be empty.");
			}
		}else{
			if((wi.getShareUserList()==null || wi.getShareUserList().isEmpty()) &&
					(wi.getShareOrgList()==null || wi.getShareOrgList().isEmpty())){
				throw new Exception("shareUserList or shareOrgList can not be empty.");
			}
		}
		Attachment2 attachment = emc.find(wi.getFileId(), Attachment2.class);
		if(attachment == null) {
			Folder2 folder = emc.find(wi.getFileId(), Folder2.class);
			if(folder==null){
				throw new ExceptionShareNotExist(wi.getFileId());
			}else{
				if (!effectivePerson.isManager() && !StringUtils.equals(folder.getPerson(), effectivePerson.getDistinguishedName())) {
					throw new Exception("person{name:" + effectivePerson.getDistinguishedName() + "} access folder{id:" + wi.getFileId()
							+ "} denied.");
				}
				share.setFileType("folder");
				share.setName(folder.getName());
				share.setPerson(folder.getPerson());
			}
		}else{
			if (!effectivePerson.isManager() && !StringUtils.equals(attachment.getPerson(), effectivePerson.getDistinguishedName())) {
				throw new Exception("person{name:" + effectivePerson.getDistinguishedName() + "} access att{id:" + wi.getFileId()
						+ "} denied.");
			}
			share.setFileType("attachment");
			share.setName(attachment.getName());
			share.setLength(attachment.getLength());
			share.setExtension(attachment.getExtension());
			share.setPerson(attachment.getPerson());
		}
		share.setLastUpdateTime(new Date());
		if(share.getValidTime()==null){
			share.setValidTime(DateTools.getDateAfterYearAdjust(new Date(),100,null,null));
		}

		emc.beginTransaction(Share.class);
		if(isExist){
			emc.check(share, CheckPersistType.all);
		}else {
			emc.persist(share, CheckPersistType.all);
		}
		emc.commit();
		if(!"password".equals(wi.getShareType())){
			if(!oldOrgList.isEmpty()){
				oldUserList.addAll(business.organization().person().listWithUnitSubNested( oldOrgList ));
			}
			List<String> newUserList = new ArrayList<>();
			newUserList.addAll(share.getShareUserList());
			if(!share.getShareOrgList().isEmpty()){
				newUserList.addAll(business.organization().person().listWithUnitSubNested( share.getShareOrgList() ));
			}
			List<String> shareAdds = ListUtils.subtract(newUserList, oldOrgList);
			ListOrderedSet<String> set = new ListOrderedSet<>();
			set.addAll(shareAdds);
			shareAdds = set.asList();
			/* 发送共享通知 */
			for (String str : shareAdds) {
				this.message_send_attachment_share(share, str);
			}
		}
		Wo wo = new Wo();
		wo.setId(share.getId());
		result.setData(wo);
		return result;
	}
}