Windchill开发-WTContainer相关API整理
Windchill开发-WTContainer相关API整理
- 概述
- 各容器对象相关方法
- 站点容器
- 组织容器
- 产品容器/存储库容器
- 上下文团队
- 角色
- 组
- 文件夹
- 方法汇总
概述
Windchill 的环境由一组容器组成,容器分为三级:第一级为站点容器,第二级为组织容器,第三极为产品容器和存储库容器。产品容器/存储库容器又由上下文团队、文件夹、业务层级对象等构成,其中上下文团队包含角色、组、用户等,业务层级对象包含部件、文档、CAD文档、升级请求等,文件夹分为默认文件夹和子文件夹。本文主要记录了各容器对象获取、上下文团队操作等方法。
各容器对象相关方法
站点容器
/*** 获取站点** @return 站点* @throws WTException*/public static ExchangeContainer getExchangeContainer() throws WTException {return WTContainerHelper.service.getExchangeContainer();}
组织容器
/*** 查询组织(按创建时间排序)** @return 组织结果集* @throws WTException*/public static QueryResult queryWTOrganizations() throws WTException {QuerySpec querySpec = new QuerySpec(WTOrganization.class);ClassAttribute name = new ClassAttribute(WTOrganization.class, WTOrganization.NAME);SearchCondition searchCondition = new SearchCondition(name, SearchCondition.NOT_NULL);querySpec.appendWhere(searchCondition, new int[1]);ClassAttribute createTime = new ClassAttribute(WTOrganization.class, WTOrganization.CREATE_TIMESTAMP);OrderBy orderBy = new OrderBy(createTime, false);querySpec.appendOrderBy(orderBy, new int[1]);QueryResult queryResult = PersistenceHelper.manager.find(querySpec);if (queryResult == null) {queryResult = new QueryResult();}return queryResult;}/*** 获取默认组织** @return 组织* @throws WTException*/public static WTOrganization getDefaultWTOrganization() throws WTException {WTOrganization organization = null;QueryResult queryResult = queryWTOrganizations();if (queryResult.hasMoreElements()) {organization = (WTOrganization) queryResult.nextElement();}return organization;}/*** 获取组织** @param orgName 组织名* @return 组织* @throws WTException*/public static WTOrganization getWTOrganization(String orgName) throws WTException {WTOrganization organization = null;if (StringUtils.hasText(orgName)) {QuerySpec querySpec = new QuerySpec(WTOrganization.class);SearchCondition searchCondition = new SearchCondition(WTOrganization.class, WTOrganization.NAME,SearchCondition.EQUAL, orgName);querySpec.appendWhere(searchCondition, new int[1]);QueryResult queryResult = PersistenceHelper.manager.find(querySpec);if (queryResult != null && queryResult.hasMoreElements()) {organization = (WTOrganization) queryResult.nextElement();}}return organization;}/*** 获取组织所在的组织容器** @param organization 组织* @return 组织容器* @throws WTException*/public static OrgContainer getOrgContainer(WTOrganization organization) throws WTException {OrgContainer orgContainer = null;if (organization != null) {orgContainer = WTContainerHelper.service.getOrgContainer(organization);}return orgContainer;}/*** 获取容器对象所在的组织容器** @param contained 容器对象(部件、文档等对象)* @return 组织容器* @throws WTException*/public static OrgContainer getOrgContainer(WTContained contained) throws WTException {OrgContainer orgContainer = null;if (contained != null) {orgContainer = WTContainerHelper.service.getOrgContainer(contained);}return orgContainer;}/*** 获取用户所在的组织容器** @param user 用户* @return 组织容器* @throws WTException*/public static OrgContainer getOrgContainer(WTUser user) throws WTException {OrgContainer orgContainer = null;if (user != null) {orgContainer = WTContainerHelper.service.getOrgContainer(user);}return orgContainer;}
说明:容器对象包含组、部件、文档、CAD文档等
产品容器/存储库容器
/*** 查询容器(产品/存储库)** @param containerName 容器名* @return 容器(产品/存储库)结果集* @throws Exception*/public static QueryResult queryWTContainer(String containerName) throws Exception {QueryResult queryResult = null;if (StringUtils.hasText(containerName)) {QuerySpec querySpec = new QuerySpec(WTContainer.class);SearchCondition searchCondition = new SearchCondition(WTContainer.class, WTContainer.NAME,SearchCondition.EQUAL, containerName);querySpec.appendWhere(searchCondition, new int[1]);querySpec.setAdvancedQueryEnabled(true);querySpec.setDescendantQuery(true);queryResult = PersistenceHelper.manager.find(querySpec);}if (queryResult == null) {queryResult = new QueryResult();}return queryResult;}/*** 获取容器(产品/存储库)(默认容器名称唯一)** @param containerName 容器名* @return 容器(产品/存储库)* @throws Exception*/public static WTContainer getWTContainer(String containerName) throws Exception {WTContainer container = null;QueryResult queryResult = queryWTContainer(containerName);if (queryResult.hasMoreElements()) {container = (WTContainer) queryResult.nextElement();}return container;}/*** 获取产品** @param productName 产品名* @return 产品* @throws WTException*/public static PDMLinkProduct getPDMLinkProduct(String productName) throws WTException {PDMLinkProduct product = null;if (StringUtils.hasText(productName)) {QuerySpec querySpec = new QuerySpec(PDMLinkProduct.class);SearchCondition searchCondition = new SearchCondition(PDMLinkProduct.class, PDMLinkProduct.NAME,SearchCondition.EQUAL, productName);querySpec.appendWhere(searchCondition, new int[1]);QueryResult queryResult = PersistenceHelper.manager.find(querySpec);if (queryResult != null && queryResult.hasMoreElements()) {product = (PDMLinkProduct) queryResult.nextElement();}}return product;}/*** 获取存储库** @param libraryName 存储库名* @return 存储库* @throws WTException*/public static WTLibrary getWTLibrary(String libraryName) throws WTException {WTLibrary library = null;if (StringUtils.hasText(libraryName)) {QuerySpec querySpec = new QuerySpec(WTLibrary.class);SearchCondition searchCondition = new SearchCondition(WTLibrary.class, WTLibrary.NAME,SearchCondition.EQUAL, libraryName);querySpec.appendWhere(searchCondition, new int[1]);QueryResult queryResult = PersistenceHelper.manager.find(querySpec);if (queryResult != null && queryResult.hasMoreElements()) {library = (WTLibrary) queryResult.nextElement();}}return library;}/*** 查询容器中的成品部件(最新且非工作副本)** @param container 容器* @return 成品部件结果集* @throws WTException*/public static QueryResult queryEndItems(WTContainer container) throws WTException {QuerySpec querySpec = new QuerySpec(WTPart.class);querySpec.appendWhere(WTContainerHelper.getWhereContainerIn(new WTContainerRef[]{WTContainerRef.newWTContainerRef(container)}), new int[1]);querySpec.appendAnd();querySpec.appendWhere(new SearchCondition(WTPart.class, WTPart.END_ITEM, SearchCondition.IS_TRUE), new int[1]);querySpec.appendAnd();querySpec.appendNot();querySpec.appendWhere(WorkInProgressHelper.getSearchCondition_CO(WTPart.class), new int[1]);querySpec.appendAnd();querySpec.appendWhere(VersionControlHelper.getSearchCondition(WTPart.class, true), new int[1]);querySpec.appendOrderBy(new OrderBy(new ClassAttribute(WTPart.class, WTPart.NUMBER), false), new int[1]);LatestConfigSpec latestConfigSpec = new LatestConfigSpec();QueryResult queryResult = ConfigHelper.service.queryIterations(querySpec, latestConfigSpec);return queryResult;}/*** 移动容器对象到目标容器(默认文件夹)** @param contained 容器对象(部件、文档等对象)* @param container 目标容器* @return 容器对象集合* @throws WTException*/public static WTCollection move(WTContained contained, WTContainer container) throws WTException {WTContainerRef containerRef = WTContainerRef.newWTContainerRef(container);Folder folder = FolderHelper.service.getFolder("/Default", containerRef);return move(contained, folder);}/*** 查询用户时间段创建的容器** @param user 用户* @param start 开始时间(可为null)* @param end 结束时间(可为null)* @return 查询结果集* @throws WTException*/public QueryResult queryCreatedContainers(WTUser user, Timestamp start, Timestamp end) throws WTException {QuerySpec querySpec = new QuerySpec(WTContainer.class);long userId = user.getPersistInfo().getObjectIdentifier().getId();SearchCondition searchCondition = new SearchCondition(WTContainer.class,WTContainer.CREATOR_REFERENCE.concat(".key.id"), SearchCondition.EQUAL, userId);querySpec.appendWhere(searchCondition, new int[1]);if (start != null) {querySpec.appendAnd();searchCondition = new SearchCondition(WTContainer.class,WTContainer.PERSIST_INFO.concat(".createStamp"), SearchCondition.GREATER_THAN_OR_EQUAL, start);querySpec.appendWhere(searchCondition, new int[1]);}if (end != null) {querySpec.appendAnd();searchCondition = new SearchCondition(WTContainer.class,WTContainer.PERSIST_INFO.concat(".createStamp"), SearchCondition.LESS_THAN_OR_EQUAL, end);querySpec.appendWhere(searchCondition, new int[1]);}QueryResult queryResult = PersistenceHelper.manager.find(querySpec);return queryResult;}
上下文团队
/*** 获取容器的上下文团队** @param managed 容器团队管理(常指容器本身)* @return 上下文团队* @throws WTException*/public static ContainerTeam getContainerTeam(ContainerTeamManaged managed) throws WTException {ContainerTeam containerTeam = null;if (managed != null) {containerTeam = ContainerTeamHelper.service.getContainerTeam(managed);}return containerTeam;}/*** 获取容器的角色集合** @param managed 容器团队管理(常指容器本身)* @return 角色集合* @throws WTException*/public static Set<Role> getRoles(ContainerTeamManaged managed) throws WTException {Set<Role> roles = new HashSet<>();ContainerTeam team = getContainerTeam(managed);Vector teamRoles = team.getRoles();roles.addAll(teamRoles);if (hasSharedTeam(managed)) {ContainerTeamReference reference = managed.getSharedTeamReference();if (reference != null) {ContainerTeam shared = (ContainerTeam) reference.getObject();if (shared != null) {Vector sharedRoles = shared.getRoles();roles.addAll(sharedRoles);}}}return roles;}/*** 判断容器是否存在共享团队** @param managed 容器团队管理(常指容器本身)* @return true代表存在* @throws WTException*/public static boolean hasSharedTeam(ContainerTeamManaged managed) {boolean flag = false;ContainerTeamManagedInfo info = managed.getContainerTeamManagedInfo();ContainerTeamReference sharedTeamId = info.getSharedTeamId();if (sharedTeamId != null) {QueryKey queryKey = sharedTeamId.getKey();if (queryKey != null) {String classname = queryKey.getClassname();if (classname != null) {flag = true;}}}return flag;}/*** 获取上下文团队角色下的用户** @param managed 容器团队管理(常指容器本身)* @param roleName 角色内部名* @return 用户集合* @throws WTException*/public static WTSet getRoleUsers(ContainerTeamManaged managed, String roleName) throws WTException {boolean enforced = SessionServerHelper.manager.setAccessEnforced(false);try {WTHashSet set = new WTHashSet();WTGroup group = ContainerTeamHelper.service.findContainerTeamGroup(managed, ContainerTeamHelper.ROLE_GROUPS, roleName);if (group != null) {Enumeration members = group.members();while (members.hasMoreElements()) {Object nextElement = members.nextElement();if (nextElement != null && nextElement instanceof WTUser) {set.add(nextElement);}}}return set;} finally {SessionServerHelper.manager.setAccessEnforced(enforced);}}/*** 获取上下文团队角色下的用户** @param managed 容器团队管理(常指容器本身)* @param role 角色* @return 用户集合* @throws WTException*/public static WTSet getRoleUsers(ContainerTeamManaged managed, Role role) throws WTException {WTSet set = new WTHashSet();if (role != null) {set = getRoleUsers(managed, role.toString());}return set;}/*** 获取上下文团队角色下的参与者** @param managed 容器团队管理(常指容器本身)* @param role 角色* @return 参与者集合* @throws WTException*/public static WTSet getRolePrincipals(ContainerTeamManaged managed, Role role) throws WTException {ContainerTeam team = getContainerTeam(managed);return getRolePrincipals(team, role);}/*** 判断参与者是否为团队成员** @param container 容器* @param principal 参与者(常指用户/组)* @return true代表是团队成员* @throws WTException*/public static boolean isTeamMember(WTContainer container, WTPrincipal principal) throws WTException {boolean flag = false;if (container != null && principal != null) {ContainerTeamManaged managed = (ContainerTeamManaged) container;WTGroup group = ContainerTeamHelper.service.findContainerTeamGroup(managed,ContainerTeamHelper.TEAM_MEMBERS, ContainerTeamHelper.TEAM_MEMBERS);if (group != null) {flag = isGroupMember(group, principal);}}return flag;}/*** 添加上下文团队角色** @param managed 容器团队管理(常指容器本身)* @param role 角色* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged addRole(ContainerTeamManaged managed, Role role) throws WTException {Set<Role> roles = new HashSet<>();if (role != null) {roles.add(role);}return addRoles(managed, roles);}/*** 添加上下文团队角色** @param managed 容器团队管理(常指容器本身)* @param roles 角色集合* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged addRoles(ContainerTeamManaged managed, Set<Role> roles) throws WTException {if (managed != null && roles != null && !roles.isEmpty()) {ContainerTeam team = getContainerTeam(managed);for (Role role : roles) {if (role != null) {ContainerTeamHelper.validateRoleName(role.toString());ContainerTeamHelper.service.addMember(team, role, null);}}managed = (ContainerTeamManaged) PersistenceHelper.manager.refresh(managed);}return managed;}/*** 移除上下文团队角色** @param managed 容器团队管理(常指容器本身)* @param role 角色* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged removeRole(ContainerTeamManaged managed, Role role) throws WTException {if (managed != null && role != null) {managed = clearRoleMember(managed, role);ContainerTeam team = getContainerTeam(managed);ContainerTeamHelper.service.removeRole(team, role);managed = (ContainerTeamManaged) PersistenceHelper.manager.refresh(managed);}return managed;}/*** 移除上下文团队角色** @param managed 容器团队管理(常指容器本身)* @param roles 角色集合* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged removeRoles(ContainerTeamManaged managed, Set<Role> roles) throws WTException {if (managed != null && roles != null && !roles.isEmpty()) {for (Role role : roles) {managed = removeRole(managed, role);}managed = (ContainerTeamManaged) PersistenceHelper.manager.refresh(managed);}return managed;}/*** 复制参与者(将源上下文团队角色的参与者复制到目标上下文团队角色)** @param sourceManaged 源容器团队管理(常指容器本身)* @param sourceRole 源角色* @param targetManaged 目标容器团队管理(常指容器本身)* @param targetRole 目标角色* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged copyPrincipals(ContainerTeamManaged sourceManaged, Role sourceRole,ContainerTeamManaged targetManaged, Role targetRole) throws WTException {if (sourceManaged != null && sourceRole != null && targetManaged != null && targetRole != null) {if (!PersistenceHelper.isEquivalent(sourceManaged, targetManaged) || !sourceRole.equals(targetRole)) {WTSet sourcePrincipals = getRolePrincipals(sourceManaged, sourceRole);Set<WTPrincipal> targetPrincipals = new HashSet<>();targetPrincipals.addAll(sourcePrincipals.persistableCollection());targetManaged = addRoleMembers(targetManaged, targetRole, targetPrincipals);}}return targetManaged;}
角色
/*** 获取角色参与者** @param holder 角色载体(常指上下文团队)* @param role 角色* @return 参与者集合* @throws WTException*/public static WTSet getRolePrincipals(WTRoleHolder2 holder, Role role) throws WTException {WTHashSet set = new WTHashSet();if (holder != null && role != null) {Enumeration<WTPrincipalReference> enumeration = holder.getPrincipalTarget(role);while (enumeration.hasMoreElements()) {WTPrincipalReference reference = enumeration.nextElement();if (reference != null && !reference.isDisabled()) {WTPrincipal principal = reference.getPrincipal();set.add(principal);}}}return set;}/*** 获取空角色集合** @param managed 容器团队管理(常指容器本身)* @param roles 目标角色集合* @return 空角色集合* @throws WTException*/public static Set<Role> getEmptyRoles(ContainerTeamManaged managed, Collection<Role> roles) throws WTException {Set<Role> emptyRoles = new HashSet<>();if (managed != null && roles != null && !roles.isEmpty()) {ContainerTeam team = getContainerTeam(managed);for (Role role : roles) {boolean hasWTUsers = hasWTUsers(team, role);if (!hasWTUsers) {emptyRoles.add(role);}}}return emptyRoles;}/*** 判断角色是否存在用户** @param holder 角色载体(常指上下文团队)* @param role 角色* @return true代表存在* @throws WTException*/public static boolean hasWTUsers(WTRoleHolder2 holder, Role role) throws WTException {boolean flag = false;WTSet users = getRolePrincipals(holder, role);if (!users.isEmpty()) {flag = true;}return flag;}/*** 判断角色是否为空** @param managed 容器团队管理(常指容器本身)* @param role 角色* @return true代表为空角色* @throws WTException*/public static boolean isEmptyRole(ContainerTeamManaged managed, Role role) throws WTException {boolean flag = true;Collection<Role> roles = new ArrayList<>();if (role != null) {roles.add(role);}Set<Role> emptyRoles = getEmptyRoles(managed, roles);if (emptyRoles.isEmpty()) {flag = false;}return flag;}/*** 判断参与者是否为角色参与者** @param managed 容器团队管理(常指容器本身)* @param role 角色* @param principal 参与者(常指用户/组)* @return true代表是角色参与者* @throws WTException*/public static boolean isRolePrincipal(ContainerTeamManaged managed, Role role, WTPrincipal principal) throws WTException {ContainerTeam team = getContainerTeam(managed);return isRolePrincipal(team, role, principal);}/*** 判断参与者是否为角色的参与者** @param holder 角色载体(常指上下文团队)* @param role 角色* @param principal 参与者(常指用户/组)* @return true代表是角色参与者* @throws WTException*/public static boolean isRolePrincipal(WTRoleHolder2 holder, Role role, WTPrincipal principal) throws WTException {boolean flag = false;if (principal != null) {if (principal instanceof WTUser) {WTUser user = (WTUser) principal;flag = isRolePrincipal(holder, role, user);} else if (principal instanceof WTGroup) {WTGroup group = (WTGroup) principal;flag = isRolePrincipal(holder, role, group);}}return flag;}/*** 判断用户是否为角色的参与者** @param holder 角色载体(常指上下文团队)* @param role 角色* @param user 用户* @return true代表是角色参与者* @throws WTException*/public static boolean isRolePrincipal(WTRoleHolder2 holder, Role role, WTUser user) throws WTException {boolean flag = false;if (holder != null && role != null && user != null) {WTSet users = getRolePrincipals(holder, role);if (users.contains(user)) {flag = true;}}return flag;}/*** 判断组是否为角色的参与者** @param holder 角色载体(常指上下文团队)* @param role 角色* @param group 组* @return true代表是角色参与者* @throws WTException*/public static boolean isRolePrincipal(WTRoleHolder2 holder, Role role, WTGroup group) throws WTException {boolean flag = false;if (holder != null && role != null && group != null) {Enumeration<WTPrincipalReference> enumeration = holder.getPrincipalTarget(role);while (enumeration.hasMoreElements()) {WTPrincipalReference reference = enumeration.nextElement();if (reference != null && !reference.isDisabled()) {WTPrincipal principal = reference.getPrincipal();if (principal instanceof WTGroup) {WTGroup teamGroup = (WTGroup) principal;if (PersistenceHelper.isEquivalent(group, teamGroup)) {flag = true;break;}WTSet groups = getChildGroups(teamGroup);if (groups.contains(group)) {flag = true;break;}}}}}return flag;}/*** 添加角色参与者(单个)** @param managed 容器团队管理(常指容器本身)* @param role 角色* @param principal 参与者(常指用户/组)* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged addRoleMember(ContainerTeamManaged managed, Role role,WTPrincipal principal) throws WTException {Set<WTPrincipal> principals = new HashSet<>();if (principal != null) {principals.add(principal);}return addRoleMembers(managed, role, principals);}/*** 添加角色参与者(批量)** @param managed 容器团队管理(常指容器本身)* @param role 角色* @param principals 参与者集合(常指用户/组)* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged addRoleMembers(ContainerTeamManaged managed, Role role,Set<WTPrincipal> principals) throws WTException {ContainerTeam team = getContainerTeam(managed);List<WTPrincipal> list = new ArrayList<>();if (principals != null && !principals.isEmpty()) {list.addAll(principals);ContainerTeamHelper.service.addMembers(team, role, list);}managed = (ContainerTeamManaged) PersistenceHelper.manager.refresh(managed);return managed;}/*** 移除角色参与者(单个)** @param managed 容器团队管理(常指容器本身)* @param role 角色* @param principal 参与者(常指用户/组)* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged removeRoleMember(ContainerTeamManaged managed, Role role,WTPrincipal principal) throws WTException {Set<WTPrincipal> principals = new HashSet<>();if (principal != null) {principals.add(principal);}return removeRoleMembers(managed, role, principals);}/*** 移除角色参与者(批量)** @param managed 容器团队管理(常指容器本身)* @param role 角色* @param principals 参与者集合(常指用户/组)* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged removeRoleMembers(ContainerTeamManaged managed, Role role,Set<WTPrincipal> principals) throws WTException {ContainerTeam team = getContainerTeam(managed);List<WTPrincipal> list = new ArrayList<>();if (principals != null && !principals.isEmpty()) {list.addAll(principals);ContainerTeamHelper.service.removeMembers(team, role, list);}managed = (ContainerTeamManaged) PersistenceHelper.manager.refresh(managed);return managed;}/*** 清空角色成员** @param managed 容器团队管理(常指容器本身)* @param role 角色* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged clearRoleMember(ContainerTeamManaged managed, Role role) throws WTException {if (managed != null && role != null) {WTSet set = getRolePrincipals(managed, role);Set<WTPrincipal> principals = new HashSet<>();principals.addAll(set.persistableCollection());managed = removeRoleMembers(managed, role, principals);managed = (ContainerTeamManaged) PersistenceHelper.manager.refresh(managed);}return managed;}/*** 清空角色成员** @param managed 容器团队管理(常指容器本身)* @param roles 角色集合* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged clearRoleMember(ContainerTeamManaged managed, Set<Role> roles) throws WTException {if (roles != null && !roles.isEmpty()) {for (Role role : roles) {managed = clearRoleMember(managed, role);}managed = (ContainerTeamManaged) PersistenceHelper.manager.refresh(managed);}return managed;}
组
/*** 判断用户是否为组成员** @param group 组* @param user 用户* @return true代表是组成员* @throws WTException*/public static boolean isGroupMember(WTGroup group, WTUser user) throws WTException {boolean flag = false;if (group != null && user != null) {flag = OrganizationServicesHelper.manager.isMember(group, user);if (!flag) {WTSet users = getChildUsers(group);if (users.contains(user)) {flag = true;}}}return flag;}/*** 判断目标组是否为源组成员** @param source 源组* @param target 目标组* @return true代表是源组成员* @throws WTException*/public static boolean isGroupMember(WTGroup source, WTGroup target) throws WTException {boolean flag = false;if (source != null && target != null) {flag = OrganizationServicesHelper.manager.isMember(source, target);if (!flag) {WTSet groups = getChildGroups(source);if (groups.contains(target)) {flag = true;}}}return flag;}/*** 判断参与者是否为组成员** @param group 组* @param principal 参与者(常指用户/组)* @return true代表是组成员* @throws WTException*/public static boolean isGroupMember(WTGroup group, WTPrincipal principal) throws WTException {boolean flag = false;if (group != null && principal != null) {if (principal instanceof WTGroup) {WTGroup target = (WTGroup) principal;flag = isGroupMember(group, target);} else if (principal instanceof WTUser) {WTUser user = (WTUser) principal;flag = isGroupMember(group, user);} else {flag = OrganizationServicesHelper.manager.isMember(group, principal);}}return flag;}/*** 获取组的直系成员集合(单层)** @param group 组* @return 成员集合* @throws WTException*/public static WTSet getImmediateMembers(WTGroup group) throws WTException {WTHashSet set = new WTHashSet();if (group != null) {Enumeration enumeration = OrganizationServicesHelper.manager.members(group, false);if (enumeration != null) {while (enumeration.hasMoreElements()) {Object nextElement = enumeration.nextElement();set.add(nextElement);}}}return set;}/*** 获取组的所有子组集合** @param group 组* @return 子组集合* @throws WTException*/public static WTSet getChildGroups(WTGroup group) throws WTException {WTHashSet set = new WTHashSet();if (group != null) {WTSet members = getImmediateMembers(group);Iterator iterator = members.persistableIterator();while (iterator.hasNext()) {Object next = iterator.next();if (next != null && next instanceof WTGroup) {WTGroup child = (WTGroup) next;set.add(child);WTSet temp = getChildGroups(child);set.addAll(temp);}}}return set;}/*** 获取组的所有子用户集合** @param group 组* @return 子用户集合* @throws WTException*/public static WTSet getChildUsers(WTGroup group) throws WTException {WTHashSet set = new WTHashSet();if (group != null) {Enumeration enumeration = OrganizationServicesHelper.manager.members(group, true);if (enumeration != null) {while (enumeration.hasMoreElements()) {Object nextElement = enumeration.nextElement();set.add(nextElement);}}}return set;}
文件夹
/*** 获取容器的默认文件夹(Default)** @param container 容器* @return 默认文件夹(Default)* @throws WTException*/public static Cabinet getDefaultFolder(WTContainer container) throws WTException {Cabinet cabinet = null;if (container != null) {WTContainerRef containerRef = WTContainerRef.newWTContainerRef(container);Folder folder = FolderHelper.service.getFolder("/Default", containerRef);if (folder != null && folder instanceof Cabinet) {cabinet = (Cabinet) folder;}}return cabinet;}/*** 获取容器的子文件夹** @param container 容器* @param folderPath 文件夹路径* @return 子文件夹* @throws WTException*/public static SubFolder getSubFolder(WTContainer container, String folderPath) throws WTException {SubFolder subFolder = null;if (container != null && StringUtils.hasText(folderPath)) {WTContainerRef containerRef = WTContainerRef.newWTContainerRef(container);Folder folder = FolderHelper.service.getFolder(folderPath, containerRef);if (folder != null && folder instanceof SubFolder) {subFolder = (SubFolder) folder;}}return subFolder;}/*** 查询文件夹内容(默认包含共享的)** @param folder 文件夹* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderContents(Folder folder) throws WTException {return queryFolderContents(folder, true);}/*** 查询文件夹内容** @param folder 文件夹* @param includeShared 是否包含共享* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderContents(Folder folder, boolean includeShared) throws WTException {QueryResult queryResult = new QueryResult();if (folder != null) {WTHashSet set = new WTHashSet();set.add(folder);WTKeyedMap map = FolderHelper.service.getFolderToContentsMap(set, FolderEntry.class, includeShared);WTSet entrySet = (WTSet) map.get(folder);if (entrySet != null) {ObjectVectorIfc vectorIfc = WTObjectHelper.parseWTCollection2ObjectVector(entrySet);queryResult = new QueryResult(vectorIfc);}}return queryResult;}/*** 查询文件夹所有内容(递归所有层子文件夹)(默认包含共享的)** @param folder 文件夹* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderAllContents(Folder folder) throws WTException {return queryFolderAllContents(folder, true);}/*** 查询文件夹所有内容(递归所有层子文件夹)** @param folder 文件夹* @param includeShared 是否包含共享* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderAllContents(Folder folder, boolean includeShared) throws WTException {QueryResult queryResult = queryFolderContents(folder, includeShared);QueryResult subFolders = FolderHelper.service.findSubFolders(folder);while (subFolders != null && subFolders.size() > 0) {WTHashSet set = new WTHashSet();set.addAll(subFolders);WTKeyedMap map = FolderHelper.service.getFolderToContentsMap(set, FolderEntry.class, includeShared);queryResult = WTObjectHelper.append2QueryResult(queryResult, map);subFolders = querySubFolders(set);}if (queryResult == null) {queryResult = new QueryResult();}return queryResult;}/*** 查询对象下的子文件夹结果集** @param set 对象集合* @return 子文件夹结果集* @throws WTException*/public static QueryResult querySubFolders(WTSet set) throws WTException {QueryResult queryResult = new QueryResult();Iterator<Persistable> iterator = set.persistableIterator();while (iterator.hasNext()) {Persistable persistable = iterator.next();if (persistable != null && persistable instanceof Folder) {Folder folder = (Folder) persistable;QueryResult subFolders = FolderHelper.service.findSubFolders(folder);if (subFolders != null && subFolders.size() > 0) {ObjectVectorIfc vectorIfc = subFolders.getObjectVectorIfc();queryResult.append(vectorIfc);}}}return queryResult;}/*** 查询文件夹最新内容(默认包含共享的)** @param folder 文件夹* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderLatestContents(Folder folder) throws WTException {return queryFolderLatestContents(folder, true);}/*** 查询文件夹最新内容** @param folder 文件夹* @param includeShared 是否包含共享* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderLatestContents(Folder folder, boolean includeShared) throws WTException {QueryResult queryResult = new QueryResult();if (folder != null) {WTHashSet set = new WTHashSet();set.add(folder);WTKeyedMap map = FolderHelper.service.getFolderToContentsMap(set, RevisionControlled.class, includeShared);WTSet entrySet = (WTSet) map.get(folder);if (entrySet != null) {ObjectVectorIfc vectorIfc = WTObjectHelper.parseWTCollection2ObjectVector(entrySet);queryResult.append(vectorIfc);LatestConfigSpec latestConfigSpec = new LatestConfigSpec();queryResult = latestConfigSpec.process(queryResult);}}return queryResult;}/*** 查询文件夹所有最新内容(递归所有层子文件夹)(默认包含共享的)** @param folder 文件夹* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderAllLatestContents(Folder folder) throws WTException {return queryFolderAllLatestContents(folder, true);}/*** 查询文件夹所有最新内容(递归所有层子文件夹)** @param folder 文件夹* @param includeShared 是否包含共享* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderAllLatestContents(Folder folder, boolean includeShared) throws WTException {QueryResult queryResult = queryFolderLatestContents(folder, includeShared);QueryResult subFolders = FolderHelper.service.findSubFolders(folder);while (subFolders != null && subFolders.size() > 0) {WTHashSet set = new WTHashSet();set.addAll(subFolders);WTKeyedMap map = FolderHelper.service.getFolderToContentsMap(set, RevisionControlled.class, includeShared);queryResult = WTObjectHelper.append2QueryResult(queryResult, map);subFolders = querySubFolders(set);}if (queryResult == null) {queryResult = new QueryResult();}return queryResult;}/*** 移动容器对象到文件夹(所有版本)** @param contained 容器对象(部件、文档等对象)* @param folder 文件夹* @return 容器对象集合* @throws WTException*/public static WTCollection move(WTContained contained, Folder folder) throws WTException {WTValuedHashMap map = new WTValuedHashMap();map.put(contained, folder);return ContainerMoveHelper.service.moveAllVersions(map);}/*** WTCollection转化为ObjectVector** @param collection 集合* @return*/public static ObjectVectorIfc parseWTCollection2ObjectVector(WTCollection collection) {Vector<Persistable> vector = new Vector<>(collection.persistableCollection());ObjectVectorIfc vectorIfc = new ObjectVector(vector);return vectorIfc;}/*** 将对象添加到结果集** @param queryResult 结果集* @param map 对象map* @return 结果集*/public static QueryResult append2QueryResult(QueryResult queryResult, WTKeyedMap map) {if (queryResult == null) {queryResult = new QueryResult();}if (map != null) {for (Object key : map.keySet()) {Object value = map.get(key);if (value != null && value instanceof WTCollection) {WTCollection collection = (WTCollection) value;ObjectVectorIfc vectorIfc = parseWTCollection2ObjectVector(collection);queryResult.append(vectorIfc);}}}return queryResult;}
方法汇总
import org.springframework.util.StringUtils;
import wt.dataops.containermove.ContainerMoveHelper;
import wt.enterprise.RevisionControlled;
import wt.fc.*;
import wt.fc.collections.*;
import wt.folder.*;
import wt.inf.container.*;
import wt.inf.library.WTLibrary;
import wt.inf.team.*;
import wt.org.*;
import wt.part.WTPart;
import wt.pdmlink.PDMLinkProduct;
import wt.project.Role;
import wt.query.*;
import wt.session.SessionServerHelper;
import wt.team.WTRoleHolder2;
import wt.util.WTException;
import wt.vc.VersionControlHelper;
import wt.vc.config.ConfigHelper;
import wt.vc.config.LatestConfigSpec;
import wt.vc.wip.WorkInProgressHelper;import java.sql.Timestamp;
import java.util.*;public class ContainerHelper {/*** 获取站点** @return 站点* @throws WTException*/public static ExchangeContainer getExchangeContainer() throws WTException {return WTContainerHelper.service.getExchangeContainer();}/*** 查询组织(按创建时间排序)** @return 组织结果集* @throws WTException*/public static QueryResult queryWTOrganizations() throws WTException {QuerySpec querySpec = new QuerySpec(WTOrganization.class);ClassAttribute name = new ClassAttribute(WTOrganization.class, WTOrganization.NAME);SearchCondition searchCondition = new SearchCondition(name, SearchCondition.NOT_NULL);querySpec.appendWhere(searchCondition, new int[1]);ClassAttribute createTime = new ClassAttribute(WTOrganization.class, WTOrganization.CREATE_TIMESTAMP);OrderBy orderBy = new OrderBy(createTime, false);querySpec.appendOrderBy(orderBy, new int[1]);QueryResult queryResult = PersistenceHelper.manager.find(querySpec);if (queryResult == null) {queryResult = new QueryResult();}return queryResult;}/*** 获取默认组织** @return 组织* @throws WTException*/public static WTOrganization getDefaultWTOrganization() throws WTException {WTOrganization organization = null;QueryResult queryResult = queryWTOrganizations();if (queryResult.hasMoreElements()) {organization = (WTOrganization) queryResult.nextElement();}return organization;}/*** 获取组织** @param orgName 组织名* @return 组织* @throws WTException*/public static WTOrganization getWTOrganization(String orgName) throws WTException {WTOrganization organization = null;if (StringUtils.hasText(orgName)) {QuerySpec querySpec = new QuerySpec(WTOrganization.class);SearchCondition searchCondition = new SearchCondition(WTOrganization.class, WTOrganization.NAME,SearchCondition.EQUAL, orgName);querySpec.appendWhere(searchCondition, new int[1]);QueryResult queryResult = PersistenceHelper.manager.find(querySpec);if (queryResult != null && queryResult.hasMoreElements()) {organization = (WTOrganization) queryResult.nextElement();}}return organization;}/*** 获取组织所在的组织容器** @param organization 组织* @return 组织容器* @throws WTException*/public static OrgContainer getOrgContainer(WTOrganization organization) throws WTException {OrgContainer orgContainer = null;if (organization != null) {orgContainer = WTContainerHelper.service.getOrgContainer(organization);}return orgContainer;}/*** 获取容器对象所在的组织容器** @param contained 容器对象(部件、文档等对象)* @return 组织容器* @throws WTException*/public static OrgContainer getOrgContainer(WTContained contained) throws WTException {OrgContainer orgContainer = null;if (contained != null) {orgContainer = WTContainerHelper.service.getOrgContainer(contained);}return orgContainer;}/*** 获取用户所在的组织容器** @param user 用户* @return 组织容器* @throws WTException*/public static OrgContainer getOrgContainer(WTUser user) throws WTException {OrgContainer orgContainer = null;if (user != null) {orgContainer = WTContainerHelper.service.getOrgContainer(user);}return orgContainer;}/*** 查询容器(产品/存储库)** @param containerName 容器名* @return 容器(产品/存储库)结果集* @throws Exception*/public static QueryResult queryWTContainer(String containerName) throws Exception {QueryResult queryResult = null;if (StringUtils.hasText(containerName)) {QuerySpec querySpec = new QuerySpec(WTContainer.class);SearchCondition searchCondition = new SearchCondition(WTContainer.class, WTContainer.NAME,SearchCondition.EQUAL, containerName);querySpec.appendWhere(searchCondition, new int[1]);querySpec.setAdvancedQueryEnabled(true);querySpec.setDescendantQuery(true);queryResult = PersistenceHelper.manager.find(querySpec);}if (queryResult == null) {queryResult = new QueryResult();}return queryResult;}/*** 获取容器(产品/存储库)(默认容器名称唯一)** @param containerName 容器名* @return 容器(产品/存储库)* @throws Exception*/public static WTContainer getWTContainer(String containerName) throws Exception {WTContainer container = null;QueryResult queryResult = queryWTContainer(containerName);if (queryResult.hasMoreElements()) {container = (WTContainer) queryResult.nextElement();}return container;}/*** 获取产品** @param productName 产品名* @return 产品* @throws WTException*/public static PDMLinkProduct getPDMLinkProduct(String productName) throws WTException {PDMLinkProduct product = null;if (StringUtils.hasText(productName)) {QuerySpec querySpec = new QuerySpec(PDMLinkProduct.class);SearchCondition searchCondition = new SearchCondition(PDMLinkProduct.class, PDMLinkProduct.NAME,SearchCondition.EQUAL, productName);querySpec.appendWhere(searchCondition, new int[1]);QueryResult queryResult = PersistenceHelper.manager.find(querySpec);if (queryResult != null && queryResult.hasMoreElements()) {product = (PDMLinkProduct) queryResult.nextElement();}}return product;}/*** 获取存储库** @param libraryName 存储库名* @return 存储库* @throws WTException*/public static WTLibrary getWTLibrary(String libraryName) throws WTException {WTLibrary library = null;if (StringUtils.hasText(libraryName)) {QuerySpec querySpec = new QuerySpec(WTLibrary.class);SearchCondition searchCondition = new SearchCondition(WTLibrary.class, WTLibrary.NAME,SearchCondition.EQUAL, libraryName);querySpec.appendWhere(searchCondition, new int[1]);QueryResult queryResult = PersistenceHelper.manager.find(querySpec);if (queryResult != null && queryResult.hasMoreElements()) {library = (WTLibrary) queryResult.nextElement();}}return library;}/*** 获取容器的默认文件夹(Default)** @param container 容器* @return 默认文件夹(Default)* @throws WTException*/public static Cabinet getDefaultFolder(WTContainer container) throws WTException {Cabinet cabinet = null;if (container != null) {WTContainerRef containerRef = WTContainerRef.newWTContainerRef(container);Folder folder = FolderHelper.service.getFolder("/Default", containerRef);if (folder != null && folder instanceof Cabinet) {cabinet = (Cabinet) folder;}}return cabinet;}/*** 获取容器的子文件夹** @param container 容器* @param folderPath 文件夹路径* @return 子文件夹* @throws WTException*/public static SubFolder getSubFolder(WTContainer container, String folderPath) throws WTException {SubFolder subFolder = null;if (container != null && StringUtils.hasText(folderPath)) {WTContainerRef containerRef = WTContainerRef.newWTContainerRef(container);Folder folder = FolderHelper.service.getFolder(folderPath, containerRef);if (folder != null && folder instanceof SubFolder) {subFolder = (SubFolder) folder;}}return subFolder;}/*** 查询文件夹内容(默认包含共享的)** @param folder 文件夹* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderContents(Folder folder) throws WTException {return queryFolderContents(folder, true);}/*** 查询文件夹内容** @param folder 文件夹* @param includeShared 是否包含共享* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderContents(Folder folder, boolean includeShared) throws WTException {QueryResult queryResult = new QueryResult();if (folder != null) {WTHashSet set = new WTHashSet();set.add(folder);WTKeyedMap map = FolderHelper.service.getFolderToContentsMap(set, FolderEntry.class, includeShared);WTSet entrySet = (WTSet) map.get(folder);if (entrySet != null) {ObjectVectorIfc vectorIfc = WTObjectHelper.parseWTCollection2ObjectVector(entrySet);queryResult = new QueryResult(vectorIfc);}}return queryResult;}/*** 查询文件夹所有内容(递归所有层子文件夹)(默认包含共享的)** @param folder 文件夹* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderAllContents(Folder folder) throws WTException {return queryFolderAllContents(folder, true);}/*** 查询文件夹所有内容(递归所有层子文件夹)** @param folder 文件夹* @param includeShared 是否包含共享* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderAllContents(Folder folder, boolean includeShared) throws WTException {QueryResult queryResult = queryFolderContents(folder, includeShared);QueryResult subFolders = FolderHelper.service.findSubFolders(folder);while (subFolders != null && subFolders.size() > 0) {WTHashSet set = new WTHashSet();set.addAll(subFolders);WTKeyedMap map = FolderHelper.service.getFolderToContentsMap(set, FolderEntry.class, includeShared);queryResult = WTObjectHelper.append2QueryResult(queryResult, map);subFolders = querySubFolders(set);}if (queryResult == null) {queryResult = new QueryResult();}return queryResult;}/*** 查询对象下的子文件夹结果集** @param set 对象集合* @return 子文件夹结果集* @throws WTException*/public static QueryResult querySubFolders(WTSet set) throws WTException {QueryResult queryResult = new QueryResult();Iterator<Persistable> iterator = set.persistableIterator();while (iterator.hasNext()) {Persistable persistable = iterator.next();if (persistable != null && persistable instanceof Folder) {Folder folder = (Folder) persistable;QueryResult subFolders = FolderHelper.service.findSubFolders(folder);if (subFolders != null && subFolders.size() > 0) {ObjectVectorIfc vectorIfc = subFolders.getObjectVectorIfc();queryResult.append(vectorIfc);}}}return queryResult;}/*** 查询文件夹最新内容(默认包含共享的)** @param folder 文件夹* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderLatestContents(Folder folder) throws WTException {return queryFolderLatestContents(folder, true);}/*** 查询文件夹最新内容** @param folder 文件夹* @param includeShared 是否包含共享* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderLatestContents(Folder folder, boolean includeShared) throws WTException {QueryResult queryResult = new QueryResult();if (folder != null) {WTHashSet set = new WTHashSet();set.add(folder);WTKeyedMap map = FolderHelper.service.getFolderToContentsMap(set, RevisionControlled.class, includeShared);WTSet entrySet = (WTSet) map.get(folder);if (entrySet != null) {ObjectVectorIfc vectorIfc = WTObjectHelper.parseWTCollection2ObjectVector(entrySet);queryResult.append(vectorIfc);LatestConfigSpec latestConfigSpec = new LatestConfigSpec();queryResult = latestConfigSpec.process(queryResult);}}return queryResult;}/*** 查询文件夹所有最新内容(递归所有层子文件夹)(默认包含共享的)** @param folder 文件夹* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderAllLatestContents(Folder folder) throws WTException {return queryFolderAllLatestContents(folder, true);}/*** 查询文件夹所有最新内容(递归所有层子文件夹)** @param folder 文件夹* @param includeShared 是否包含共享* @return 查询结果集* @throws WTException*/public static QueryResult queryFolderAllLatestContents(Folder folder, boolean includeShared) throws WTException {QueryResult queryResult = queryFolderLatestContents(folder, includeShared);QueryResult subFolders = FolderHelper.service.findSubFolders(folder);while (subFolders != null && subFolders.size() > 0) {WTHashSet set = new WTHashSet();set.addAll(subFolders);WTKeyedMap map = FolderHelper.service.getFolderToContentsMap(set, RevisionControlled.class, includeShared);queryResult = WTObjectHelper.append2QueryResult(queryResult, map);subFolders = querySubFolders(set);}if (queryResult == null) {queryResult = new QueryResult();}return queryResult;}/*** 查询容器中的成品部件(最新且非工作副本)** @param container 容器* @return 成品部件结果集* @throws WTException*/public static QueryResult queryEndItems(WTContainer container) throws WTException {QuerySpec querySpec = new QuerySpec(WTPart.class);querySpec.appendWhere(WTContainerHelper.getWhereContainerIn(new WTContainerRef[]{WTContainerRef.newWTContainerRef(container)}), new int[1]);querySpec.appendAnd();querySpec.appendWhere(new SearchCondition(WTPart.class, WTPart.END_ITEM, SearchCondition.IS_TRUE), new int[1]);querySpec.appendAnd();querySpec.appendNot();querySpec.appendWhere(WorkInProgressHelper.getSearchCondition_CO(WTPart.class), new int[1]);querySpec.appendAnd();querySpec.appendWhere(VersionControlHelper.getSearchCondition(WTPart.class, true), new int[1]);querySpec.appendOrderBy(new OrderBy(new ClassAttribute(WTPart.class, WTPart.NUMBER), false), new int[1]);LatestConfigSpec latestConfigSpec = new LatestConfigSpec();QueryResult queryResult = ConfigHelper.service.queryIterations(querySpec, latestConfigSpec);return queryResult;}/*** 移动容器对象到目标容器(默认文件夹)** @param contained 容器对象(部件、文档等对象)* @param container 目标容器* @return 容器对象集合* @throws WTException*/public static WTCollection move(WTContained contained, WTContainer container) throws WTException {WTContainerRef containerRef = WTContainerRef.newWTContainerRef(container);Folder folder = FolderHelper.service.getFolder("/Default", containerRef);return move(contained, folder);}/*** 移动容器对象到文件夹(所有版本)** @param contained 容器对象(部件、文档等对象)* @param folder 文件夹* @return 容器对象集合* @throws WTException*/public static WTCollection move(WTContained contained, Folder folder) throws WTException {WTValuedHashMap map = new WTValuedHashMap();map.put(contained, folder);return ContainerMoveHelper.service.moveAllVersions(map);}/*** 查询用户时间段创建的容器** @param user 用户* @param start 开始时间(可为null)* @param end 结束时间(可为null)* @return 查询结果集* @throws WTException*/public QueryResult queryCreatedContainers(WTUser user, Timestamp start, Timestamp end) throws WTException {QuerySpec querySpec = new QuerySpec(WTContainer.class);long userId = user.getPersistInfo().getObjectIdentifier().getId();SearchCondition searchCondition = new SearchCondition(WTContainer.class,WTContainer.CREATOR_REFERENCE.concat(".key.id"), SearchCondition.EQUAL, userId);querySpec.appendWhere(searchCondition, new int[1]);if (start != null) {querySpec.appendAnd();searchCondition = new SearchCondition(WTContainer.class,WTContainer.PERSIST_INFO.concat(".createStamp"), SearchCondition.GREATER_THAN_OR_EQUAL, start);querySpec.appendWhere(searchCondition, new int[1]);}if (end != null) {querySpec.appendAnd();searchCondition = new SearchCondition(WTContainer.class,WTContainer.PERSIST_INFO.concat(".createStamp"), SearchCondition.LESS_THAN_OR_EQUAL, end);querySpec.appendWhere(searchCondition, new int[1]);}QueryResult queryResult = PersistenceHelper.manager.find(querySpec);return queryResult;}/*** 获取容器的上下文团队** @param managed 容器团队管理(常指容器本身)* @return 上下文团队* @throws WTException*/public static ContainerTeam getContainerTeam(ContainerTeamManaged managed) throws WTException {ContainerTeam containerTeam = null;if (managed != null) {containerTeam = ContainerTeamHelper.service.getContainerTeam(managed);}return containerTeam;}/*** 获取容器的角色集合** @param managed 容器团队管理(常指容器本身)* @return 角色集合* @throws WTException*/public static Set<Role> getRoles(ContainerTeamManaged managed) throws WTException {Set<Role> roles = new HashSet<>();ContainerTeam team = getContainerTeam(managed);Vector teamRoles = team.getRoles();roles.addAll(teamRoles);if (hasSharedTeam(managed)) {ContainerTeamReference reference = managed.getSharedTeamReference();if (reference != null) {ContainerTeam shared = (ContainerTeam) reference.getObject();if (shared != null) {Vector sharedRoles = shared.getRoles();roles.addAll(sharedRoles);}}}return roles;}/*** 判断容器是否存在共享团队** @param managed 容器团队管理(常指容器本身)* @return true代表存在* @throws WTException*/public static boolean hasSharedTeam(ContainerTeamManaged managed) {boolean flag = false;ContainerTeamManagedInfo info = managed.getContainerTeamManagedInfo();ContainerTeamReference sharedTeamId = info.getSharedTeamId();if (sharedTeamId != null) {QueryKey queryKey = sharedTeamId.getKey();if (queryKey != null) {String classname = queryKey.getClassname();if (classname != null) {flag = true;}}}return flag;}/*** 获取上下文团队角色下的用户** @param managed 容器团队管理(常指容器本身)* @param roleName 角色内部名* @return 用户集合* @throws WTException*/public static WTSet getRoleUsers(ContainerTeamManaged managed, String roleName) throws WTException {boolean enforced = SessionServerHelper.manager.setAccessEnforced(false);try {WTHashSet set = new WTHashSet();WTGroup group = ContainerTeamHelper.service.findContainerTeamGroup(managed, ContainerTeamHelper.ROLE_GROUPS, roleName);if (group != null) {Enumeration members = group.members();while (members.hasMoreElements()) {Object nextElement = members.nextElement();if (nextElement != null && nextElement instanceof WTUser) {set.add(nextElement);}}}return set;} finally {SessionServerHelper.manager.setAccessEnforced(enforced);}}/*** 获取上下文团队角色下的用户** @param managed 容器团队管理(常指容器本身)* @param role 角色* @return 用户集合* @throws WTException*/public static WTSet getRoleUsers(ContainerTeamManaged managed, Role role) throws WTException {WTSet set = new WTHashSet();if (role != null) {set = getRoleUsers(managed, role.toString());}return set;}/*** 获取上下文团队角色下的参与者** @param managed 容器团队管理(常指容器本身)* @param role 角色* @return 参与者集合* @throws WTException*/public static WTSet getRolePrincipals(ContainerTeamManaged managed, Role role) throws WTException {ContainerTeam team = getContainerTeam(managed);return getRolePrincipals(team, role);}/*** 获取空角色集合** @param managed 容器团队管理(常指容器本身)* @param roles 目标角色集合* @return 空角色集合* @throws WTException*/public static Set<Role> getEmptyRoles(ContainerTeamManaged managed, Collection<Role> roles) throws WTException {Set<Role> emptyRoles = new HashSet<>();if (managed != null && roles != null && !roles.isEmpty()) {ContainerTeam team = getContainerTeam(managed);for (Role role : roles) {boolean hasWTUsers = hasWTUsers(team, role);if (!hasWTUsers) {emptyRoles.add(role);}}}return emptyRoles;}/*** 判断角色是否为空** @param managed 容器团队管理(常指容器本身)* @param role 角色* @return true代表为空角色* @throws WTException*/public static boolean isEmptyRole(ContainerTeamManaged managed, Role role) throws WTException {boolean flag = true;Collection<Role> roles = new ArrayList<>();if (role != null) {roles.add(role);}Set<Role> emptyRoles = getEmptyRoles(managed, roles);if (emptyRoles.isEmpty()) {flag = false;}return flag;}/*** 判断参与者是否为角色参与者** @param managed 容器团队管理(常指容器本身)* @param role 角色* @param principal 参与者(常指用户/组)* @return true代表是角色参与者* @throws WTException*/public static boolean isRolePrincipal(ContainerTeamManaged managed, Role role, WTPrincipal principal) throws WTException {ContainerTeam team = getContainerTeam(managed);return isRolePrincipal(team, role, principal);}/*** 判断参与者是否为团队成员** @param container 容器* @param principal 参与者(常指用户/组)* @return true代表是团队成员* @throws WTException*/public static boolean isTeamMember(WTContainer container, WTPrincipal principal) throws WTException {boolean flag = false;if (container != null && principal != null) {ContainerTeamManaged managed = (ContainerTeamManaged) container;WTGroup group = ContainerTeamHelper.service.findContainerTeamGroup(managed,ContainerTeamHelper.TEAM_MEMBERS, ContainerTeamHelper.TEAM_MEMBERS);if (group != null) {flag = isGroupMember(group, principal);}}return flag;}/*** 添加角色参与者(单个)** @param managed 容器团队管理(常指容器本身)* @param role 角色* @param principal 参与者(常指用户/组)* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged addRoleMember(ContainerTeamManaged managed, Role role,WTPrincipal principal) throws WTException {Set<WTPrincipal> principals = new HashSet<>();if (principal != null) {principals.add(principal);}return addRoleMembers(managed, role, principals);}/*** 添加角色参与者(批量)** @param managed 容器团队管理(常指容器本身)* @param role 角色* @param principals 参与者集合(常指用户/组)* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged addRoleMembers(ContainerTeamManaged managed, Role role,Set<WTPrincipal> principals) throws WTException {ContainerTeam team = getContainerTeam(managed);List<WTPrincipal> list = new ArrayList<>();if (principals != null && !principals.isEmpty()) {list.addAll(principals);ContainerTeamHelper.service.addMembers(team, role, list);}managed = (ContainerTeamManaged) PersistenceHelper.manager.refresh(managed);return managed;}/*** 移除角色参与者(单个)** @param managed 容器团队管理(常指容器本身)* @param role 角色* @param principal 参与者(常指用户/组)* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged removeRoleMember(ContainerTeamManaged managed, Role role,WTPrincipal principal) throws WTException {Set<WTPrincipal> principals = new HashSet<>();if (principal != null) {principals.add(principal);}return removeRoleMembers(managed, role, principals);}/*** 移除角色参与者(批量)** @param managed 容器团队管理(常指容器本身)* @param role 角色* @param principals 参与者集合(常指用户/组)* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged removeRoleMembers(ContainerTeamManaged managed, Role role,Set<WTPrincipal> principals) throws WTException {ContainerTeam team = getContainerTeam(managed);List<WTPrincipal> list = new ArrayList<>();if (principals != null && !principals.isEmpty()) {list.addAll(principals);ContainerTeamHelper.service.removeMembers(team, role, list);}managed = (ContainerTeamManaged) PersistenceHelper.manager.refresh(managed);return managed;}/*** 清空角色成员** @param managed 容器团队管理(常指容器本身)* @param role 角色* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged clearRoleMember(ContainerTeamManaged managed, Role role) throws WTException {if (managed != null && role != null) {WTSet set = getRolePrincipals(managed, role);Set<WTPrincipal> principals = new HashSet<>();principals.addAll(set.persistableCollection());managed = removeRoleMembers(managed, role, principals);managed = (ContainerTeamManaged) PersistenceHelper.manager.refresh(managed);}return managed;}/*** 清空角色成员** @param managed 容器团队管理(常指容器本身)* @param roles 角色集合* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged clearRoleMember(ContainerTeamManaged managed, Set<Role> roles) throws WTException {if (roles != null && !roles.isEmpty()) {for (Role role : roles) {managed = clearRoleMember(managed, role);}managed = (ContainerTeamManaged) PersistenceHelper.manager.refresh(managed);}return managed;}/*** 添加上下文团队角色** @param managed 容器团队管理(常指容器本身)* @param role 角色* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged addRole(ContainerTeamManaged managed, Role role) throws WTException {Set<Role> roles = new HashSet<>();if (role != null) {roles.add(role);}return addRoles(managed, roles);}/*** 添加上下文团队角色** @param managed 容器团队管理(常指容器本身)* @param roles 角色集合* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged addRoles(ContainerTeamManaged managed, Set<Role> roles) throws WTException {if (managed != null && roles != null && !roles.isEmpty()) {ContainerTeam team = getContainerTeam(managed);for (Role role : roles) {if (role != null) {ContainerTeamHelper.validateRoleName(role.toString());ContainerTeamHelper.service.addMember(team, role, null);}}managed = (ContainerTeamManaged) PersistenceHelper.manager.refresh(managed);}return managed;}/*** 移除上下文团队角色** @param managed 容器团队管理(常指容器本身)* @param role 角色* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged removeRole(ContainerTeamManaged managed, Role role) throws WTException {if (managed != null && role != null) {managed = clearRoleMember(managed, role);ContainerTeam team = getContainerTeam(managed);ContainerTeamHelper.service.removeRole(team, role);managed = (ContainerTeamManaged) PersistenceHelper.manager.refresh(managed);}return managed;}/*** 移除上下文团队角色** @param managed 容器团队管理(常指容器本身)* @param roles 角色集合* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged removeRoles(ContainerTeamManaged managed, Set<Role> roles) throws WTException {if (managed != null && roles != null && !roles.isEmpty()) {for (Role role : roles) {managed = removeRole(managed, role);}managed = (ContainerTeamManaged) PersistenceHelper.manager.refresh(managed);}return managed;}/*** 复制参与者(将源上下文团队角色的参与者复制到目标上下文团队角色)** @param sourceManaged 源容器团队管理(常指容器本身)* @param sourceRole 源角色* @param targetManaged 目标容器团队管理(常指容器本身)* @param targetRole 目标角色* @return 容器团队管理(常指容器本身)* @throws WTException*/public static ContainerTeamManaged copyPrincipals(ContainerTeamManaged sourceManaged, Role sourceRole,ContainerTeamManaged targetManaged, Role targetRole) throws WTException {if (sourceManaged != null && sourceRole != null && targetManaged != null && targetRole != null) {if (!PersistenceHelper.isEquivalent(sourceManaged, targetManaged) || !sourceRole.equals(targetRole)) {WTSet sourcePrincipals = getRolePrincipals(sourceManaged, sourceRole);Set<WTPrincipal> targetPrincipals = new HashSet<>();targetPrincipals.addAll(sourcePrincipals.persistableCollection());targetManaged = addRoleMembers(targetManaged, targetRole, targetPrincipals);}}return targetManaged;}/*** 获取角色参与者** @param holder 角色载体(常指上下文团队)* @param role 角色* @return 参与者集合* @throws WTException*/public static WTSet getRolePrincipals(WTRoleHolder2 holder, Role role) throws WTException {WTHashSet set = new WTHashSet();if (holder != null && role != null) {Enumeration<WTPrincipalReference> enumeration = holder.getPrincipalTarget(role);while (enumeration.hasMoreElements()) {WTPrincipalReference reference = enumeration.nextElement();if (reference != null && !reference.isDisabled()) {WTPrincipal principal = reference.getPrincipal();set.add(principal);}}}return set;}/*** 判断角色是否存在用户** @param holder 角色载体(常指上下文团队)* @param role 角色* @return true代表存在* @throws WTException*/public static boolean hasWTUsers(WTRoleHolder2 holder, Role role) throws WTException {boolean flag = false;WTSet users = getRolePrincipals(holder, role);if (!users.isEmpty()) {flag = true;}return flag;}/*** 判断参与者是否为角色的参与者** @param holder 角色载体(常指上下文团队)* @param role 角色* @param principal 参与者(常指用户/组)* @return true代表是角色参与者* @throws WTException*/public static boolean isRolePrincipal(WTRoleHolder2 holder, Role role, WTPrincipal principal) throws WTException {boolean flag = false;if (principal != null) {if (principal instanceof WTUser) {WTUser user = (WTUser) principal;flag = isRolePrincipal(holder, role, user);} else if (principal instanceof WTGroup) {WTGroup group = (WTGroup) principal;flag = isRolePrincipal(holder, role, group);}}return flag;}/*** 判断用户是否为角色的参与者** @param holder 角色载体(常指上下文团队)* @param role 角色* @param user 用户* @return true代表是角色参与者* @throws WTException*/public static boolean isRolePrincipal(WTRoleHolder2 holder, Role role, WTUser user) throws WTException {boolean flag = false;if (holder != null && role != null && user != null) {WTSet users = getRolePrincipals(holder, role);if (users.contains(user)) {flag = true;}}return flag;}/*** 判断组是否为角色的参与者** @param holder 角色载体(常指上下文团队)* @param role 角色* @param group 组* @return true代表是角色参与者* @throws WTException*/public static boolean isRolePrincipal(WTRoleHolder2 holder, Role role, WTGroup group) throws WTException {boolean flag = false;if (holder != null && role != null && group != null) {Enumeration<WTPrincipalReference> enumeration = holder.getPrincipalTarget(role);while (enumeration.hasMoreElements()) {WTPrincipalReference reference = enumeration.nextElement();if (reference != null && !reference.isDisabled()) {WTPrincipal principal = reference.getPrincipal();if (principal instanceof WTGroup) {WTGroup teamGroup = (WTGroup) principal;if (PersistenceHelper.isEquivalent(group, teamGroup)) {flag = true;break;}WTSet groups = getChildGroups(teamGroup);if (groups.contains(group)) {flag = true;break;}}}}}return flag;}/*** 获取组的直系成员集合(单层)** @param group 组* @return 成员集合* @throws WTException*/public static WTSet getImmediateMembers(WTGroup group) throws WTException {WTHashSet set = new WTHashSet();if (group != null) {Enumeration enumeration = OrganizationServicesHelper.manager.members(group, false);if (enumeration != null) {while (enumeration.hasMoreElements()) {Object nextElement = enumeration.nextElement();set.add(nextElement);}}}return set;}/*** 获取组的所有子组集合** @param group 组* @return 子组集合* @throws WTException*/public static WTSet getChildGroups(WTGroup group) throws WTException {WTHashSet set = new WTHashSet();if (group != null) {WTSet members = getImmediateMembers(group);Iterator iterator = members.persistableIterator();while (iterator.hasNext()) {Object next = iterator.next();if (next != null && next instanceof WTGroup) {WTGroup child = (WTGroup) next;set.add(child);WTSet temp = getChildGroups(child);set.addAll(temp);}}}return set;}/*** 获取组的所有子用户集合** @param group 组* @return 子用户集合* @throws WTException*/public static WTSet getChildUsers(WTGroup group) throws WTException {WTHashSet set = new WTHashSet();if (group != null) {Enumeration enumeration = OrganizationServicesHelper.manager.members(group, true);if (enumeration != null) {while (enumeration.hasMoreElements()) {Object nextElement = enumeration.nextElement();set.add(nextElement);}}}return set;}/*** 判断用户是否为组成员** @param group 组* @param user 用户* @return true代表是组成员* @throws WTException*/public static boolean isGroupMember(WTGroup group, WTUser user) throws WTException {boolean flag = false;if (group != null && user != null) {flag = OrganizationServicesHelper.manager.isMember(group, user);if (!flag) {WTSet users = getChildUsers(group);if (users.contains(user)) {flag = true;}}}return flag;}/*** 判断目标组是否为源组成员** @param source 源组* @param target 目标组* @return true代表是源组成员* @throws WTException*/public static boolean isGroupMember(WTGroup source, WTGroup target) throws WTException {boolean flag = false;if (source != null && target != null) {flag = OrganizationServicesHelper.manager.isMember(source, target);if (!flag) {WTSet groups = getChildGroups(source);if (groups.contains(target)) {flag = true;}}}return flag;}/*** 判断参与者是否为组成员** @param group 组* @param principal 参与者(常指用户/组)* @return true代表是组成员* @throws WTException*/public static boolean isGroupMember(WTGroup group, WTPrincipal principal) throws WTException {boolean flag = false;if (group != null && principal != null) {if (principal instanceof WTGroup) {WTGroup target = (WTGroup) principal;flag = isGroupMember(group, target);} else if (principal instanceof WTUser) {WTUser user = (WTUser) principal;flag = isGroupMember(group, user);} else {flag = OrganizationServicesHelper.manager.isMember(group, principal);}}return flag;}/*** WTCollection转化为ObjectVector** @param collection 集合* @return*/public static ObjectVectorIfc parseWTCollection2ObjectVector(WTCollection collection) {Vector<Persistable> vector = new Vector<>(collection.persistableCollection());ObjectVectorIfc vectorIfc = new ObjectVector(vector);return vectorIfc;}/*** 将对象添加到结果集** @param queryResult 结果集* @param map 对象map* @return 结果集*/public static QueryResult append2QueryResult(QueryResult queryResult, WTKeyedMap map) {if (queryResult == null) {queryResult = new QueryResult();}if (map != null) {for (Object key : map.keySet()) {Object value = map.get(key);if (value != null && value instanceof WTCollection) {WTCollection collection = (WTCollection) value;ObjectVectorIfc vectorIfc = parseWTCollection2ObjectVector(collection);queryResult.append(vectorIfc);}}}return queryResult;}
}
相关文章:
Windchill开发-WTContainer相关API整理
Windchill开发-WTContainer相关API整理 概述各容器对象相关方法站点容器组织容器产品容器/存储库容器上下文团队角色组 文件夹 方法汇总 概述 Windchill 的环境由一组容器组成,容器分为三级:第一级为站点容器,第二级为组织容器,第…...
理解JSON-RPC 2.0 协议
JSON-RPC 2.0是指一种基于 JSON 的远程过程调用协议,用于在网络上进行跨平台和跨语言的通信。它提供了一种简单、轻量级的方式来实现客户端和服务器之间的方法调用和数据交换。在原文中,JSON-RPC 2.0被用来描述 STDIO 传输机制中消息的格式,即…...
【 C# 使用 MiniExcel 库的典型场景】
以下是 C# 使用 MiniExcel 库的典型场景及代码示例: 一、基础读取操作 强类型读取(需定义数据模型类) 定义与 Excel 列名匹配的类后直接映射为对象集合: csharp Copy Code public class UserAccount { public int Id { get; …...
创建 Pod 失败,运行时报错 no space left on device?
遇到创建Pod失败并报错“no space left on device”时,请按照以下步骤排查和解决问题: 1. 定位问题来源 查看Pod事件: kubectl describe pod <pod-name> -n <namespace> 在输出中查找 Events 部分,确认错误是否与…...
[leetcode]查询区间内的所有素数
一.暴力求解 #include<iostream> #include<vector> using namespace std; vector<int> result; bool isPrime(int i) { if (i < 2) return false; for (int j 2;j * j < i;j) { if (i % j 0) { …...
【Web安全】如何在 CDN 干扰下精准检测 SSRF?Nuclei + Interactsh 实战
❤️博客主页: iknow181 🔥系列专栏: 网络安全、 Python、JavaSE、JavaWeb、CCNP 🎉欢迎大家点赞👍收藏⭐评论✍ 背景 在日常漏洞复核中,我们常用 DNSLog 平台判断目标是否存在 SSRF 漏洞:只要请…...
输入框只能输入非中文字符
在 Qt 中,可以通过设置输入法过滤器(QInputContext)或使用正则表达式来限制输入框(QLineEdit 或 QTextEdit)只能输入非中文字符。以下是两种实现方法: ### 方法 1:使用正则表达式 可以通过 QLi…...
LeeCode 136. 只出现一次的数字
给你一个 非空 整数数组 nums ,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。 你必须设计并实现线性时间复杂度的算法来解决此问题,且该算法只使用常量额外空间。 示例 1 : 输入࿱…...
Traefik应用:配置容器多个网络时无法访问问题
Traefik应用:配置容器多个网络时无法访问问题 介绍解决方法问题原因: **容器多网络归属导致 Traefik 无法正确发现路由规则**。解决方案方法 1:将应用容器 **仅连接** 到 traefik-public 网络方法 2:显式指定 Traefik 监听的网络 …...
超便捷超实用的文档处理工具,PDF排序,功能强大,应用广泛,无需下载,在线使用,简单易用快捷!
小白工具https://www.xiaobaitool.net/files/pdf-sort/ 中的 PDF 排序功能是一项便捷实用的文档处理服务,以下是其具体介绍: 操作便捷直观:用户上传 PDF 文件后,可通过直接拖动页面缩略图来调整顺序,就像在纸质文档中…...
zsh: command not found - 鸿蒙 HarmonyOS Next
终端中执行 hdc 命令抛出如下错误; zsh: command not found 解决办法 首先,查找到 DevEco-Studio 的 toolchains 目录路径; 其次,按照类似如下的文件夹层级结果推理到 toolchains 子级路径下,其中 sdk 后一级的路径可能会存在差异,以实际本地路径结构为主,直至找到 openharm…...
【动态规划】 深入动态规划—两个数组的dp问题
文章目录 前言例题一、最长公共子序列二、不相交的线三、不同的子序列四、通配符匹配五、交错字符串六、两个字符串的最小ASCII删除和七、最长重复子数组 结语 前言 问题本质 它主要围绕着给定的两个数组展开,旨在通过对这两个数组元素间关系的分析,找出…...
金融数据分析(Python)个人学习笔记(7):网络数据采集以及FNN分类
一、网络数据采集 证券宝是一个免费、开源的证券数据平台(无需注册),提供大盘准确、完整的证券历史行情数据、上市公司财务数据等,通过python API获取证券数据信息。 1. 安装并导入第三方依赖库 baostock 在命令提示符中运行&…...
指定运行级别
linux系统下有7种运行级别,我们需要来了解一下常用的运行级别,方便我们熟悉以后的部署环境,话不多说,来看. 开机流程: 指定数级别 基本介绍 运行级别说明: 0:关机 相当于shutdown -h now ⭐️默认参数不能设置为0,否则系统无法正常启动 1:单用户(用于找回丢…...
7.第二阶段x64游戏实战-string类
免责声明:内容仅供学习参考,请合法利用知识,禁止进行违法犯罪活动! 本次游戏没法给 内容参考于:微尘网络安全 上一个内容:7.第二阶段x64游戏实战-分析人物属性 string类是字符串类,在计算机中…...
【MySQL基础】左右连接实战:掌握数据关联的完整视图
1 左右连接基础概念 左连接(left join)和右连接(right join)是MySQL中两种重要的表连接方式,它们与内连接不同,能够保留不匹配的记录,为我们提供更完整的数据视图。 核心区别: left join:保留左表所有记录,…...
建筑工程行业如何选OA系统?4大主流产品分析
工程行业项目的复杂性与业务流程的繁琐性对办公效率提出了极高要求。而OA 系统(办公自动化系统)的出现,为工程企业提供了一种全新的、高效的管理模式。 工程行业OA系统选型关键指标 功能深度:项目管理模块完整度、文档版本控制能…...
动态科技感html导航网站源码
源码介绍 动态科技感html导航网站源码,这个设计完美呈现了科幻电影中的未来科技界面效果,适合展示技术类项目或作为个人作品集的入口页面,自适应手机。 修改卡片中的链接指向你实际的HTML文件可以根据需要调整卡片内容、图标和颜色要添加更…...
CLIPGaze: Zero-Shot Goal-Directed ScanpathPrediction Using CLIP
摘要 目标导向的扫描路径预测旨在预测人们在搜索视觉场景中的目标时的视线移动路径。大多数现有的目标导向扫描路径预测方法在面对训练过程中未出现的目标类别时,泛化能力较差。此外,它们通常采用不同的预训练模型分别提取目标提示和图像的特征,导致两者之间存在较大的特征…...
wsl-docker环境下启动ES报错vm.max_map_count [65530] is too low
问题描述 在windows环境下用Docker Desktop(wsl docker)启动 elasticsearch时报错 max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]解决方案 方案一 默认的vm.max_map_count值是65530,而es需要至少262…...
js chrome 插件,下载微博视频
起因, 目的: 最初是想下载微博上的NBA视频,因为在看网页上看视频很不方便,快进一次是10秒,而本地 VLC 播放器,快进一次是5秒。另外我还想做点视频剪辑。 对比 原来手动下载的话,右键检查,复制…...
游戏引擎学习第212天
"我们将同步…"α 之前我们有一些内容是暂时搁置的,因为在调整代码的过程中,我们做了一些变动以使代码更加简洁,这样可以把数据放入调试缓冲区并显示出来,这一切现在看起来已经好多了。尽管现在看起来更好,…...
PXE远程安装服务器
目录 搭建PXE远程安装服务器 1、准备Linux安装源: 2、安装并启用TFTP服务: 3、准备Linux内核、初始化镜像文件 4、准备PXE引导程序 5、安装并启用DHCP服务 6、(1)配置启动菜单文件(有人应答) 6、(2)…...
软件测试之功能测试详解
一、测试项目启动与研读需求文档 (一) 组建测试团队 1、测试团队中的角色 2、测试团队的基本责任 尽早地发现软件程序、系统或产品中所有的问题。 督促和协助开发人员尽快地解决程序中的缺陷。 帮助项目管理人员制定合理的开发和测试计划。 对缺陷进行…...
Python深度学习基础——卷积神经网络(CNN)(PyTorch)
CNN原理 从DNN到CNN 卷积层与汇聚 深度神经网络DNN中,相邻层的所有神经元之间都有连接,这叫全连接;卷积神经网络 CNN 中,新增了卷积层(Convolution)与汇聚(Pooling)。DNN 的全连接…...
pytorch 反向传播
文章目录 概念计算图自动求导的两种模式 自动求导-代码标量的反向传播非标量变量的反向传播将某些计算移动到计算图之外 概念 核心:链式法则 深度学习框架通过自动计算导数(自动微分)来加快求导。 实践中,根据涉及号的模型,系统会构建一个计…...
VSCode解决中文乱码方法
目录 一、底层原因 二、解决方法原理 三、解决方式: 1.预设更改cmd临时编码法 2.安装插件法: 一、底层原因 当在VSCode中遇到中文显示乱码的问题时,这通常是由于文件编码与VSCode的默认或设置编码不匹配,或…...
pandas.DataFrame.dtypes--查看和验证 DataFrame 列的数据类型!
查看每列的数据类型,方便分析是否需要数据类型转换 property DataFrame.dtypes[source] Return the dtypes in the DataFrame. This returns a Series with the data type of each column. The result’s index is the original DataFrame’s columns. Columns with…...
高性能服务开发利器:redis+lua
Redis 与 Lua 脚本的结合,其核心价值在于 原子性操作 和 减少网络开销。 一、Redis 执行 Lua 脚本的优势 原子性 Lua 脚本在 Redis 中原子执行,避免多命令竞态条件。 减少网络开销 将多个 Redis 命令合并为一个脚本,减少客…...
开源智能体MetaGPT记忆模块解读
MetaGPT 智能体框架 1. 框架概述 MetaGPT 是一个多智能体协作框架,通过模拟软件公司组织架构与工作流程,将大语言模型(LLM)转化为具备专业分工的智能体,协同完成复杂任务。其最大特点是能够将自然语言需…...
Docker部署MySQL大小写不敏感配置与数据迁移实战20250409
Docker部署MySQL大小写不敏感配置与数据迁移实战 🧭 引言 在企业实际应用中,尤其是使用Java、Hibernate等框架开发的系统,MySQL默认的大小写敏感特性容易引发各种兼容性问题。特别是在Linux系统中部署Docker版MySQL时,默认行为可…...
【RabbitMQ】延迟队列
1.概述 延迟队列其实就是队列里的消息是希望在指定时间到了以后或之前取出和处理,简单来说,延时队列就是用来存放需要在指定时间被处理的元素的队列。 延时队列的使用场景: 1.订单在十分钟之内未支付则自动取消 2.新创建的店铺,…...
深兰科技携多款AI医疗创新成果亮相第七届世界大健康博览会
4月8日,以“AI赋能 健康生活”为主题的2025年(第七届)世界大健康博览会(以下简称健博会)在武汉隆重开幕。应参展企业武汉市三甲医院——武汉中心医院的邀请,深兰科技最新研发的新一代智慧医疗解决方案和产品在其展位上公开亮相。 本届展会吸引了来自18个…...
20周年系列|美创科技再度入围「年度高成长企业」系列榜单
近日,资深产业信息服务平台【第一新声】发布「2024年度科技行业最佳CEO及高成长企业榜」,美创科技凭借在数据安全领域的持续创新和广泛行业实践, 再度入围“年度网络安全高成长企业”、“年度高科技高成长未来独角兽企业TOP30”。 美创科技作…...
saltstack分布式部署
一、saltstack分布式 在minion数量过多时,通过部署salt代理,减轻master负载 1、在master上删除说有minion证书 2、在minion上删除旧master信息 3、安装部署salt-syndic 4、修改minion 5、在master上签署代理的证书 6、在代理上签署minion证书 7、测试...
CCRC 与 EMVCo 双认证:中国智能卡企业的全球化突围
在全球经济一体化的浪潮中,智能卡行业正经历着前所未有的变革与发展。中国智能卡企业凭借技术优势与成本竞争力,在国内市场成绩斐然。然而,要想在国际市场站稳脚跟,获取权威认证成为关键一步。CCRC 与 EMVCo 双认证,宛…...
逆向工程的多层次解析:从实现到领域的全面视角
目录 前言1. 什么是逆向工程?2. 实现级逆向:揭示代码背后的结构2.1 抽象语法树的构建2.2 符号表的恢复2.3 过程设计表示的推导 3. 结构级逆向:重建模块之间的协作关系3.1 调用图与依赖分析3.2 程序与数据结构的映射 4. 功能级逆向:…...
【Docker项目实战】使用Docker部署ToDoList任务管理工具
【Docker项目实战】使用Docker部署ToDoList任务管理工具 一、ToDoList介绍1.1 ToDoList简介1.2 ToDoList主要特点二、本次实践规划2.1 本地环境规划2.2 本次实践介绍三、本地环境检查3.1 检查Docker服务状态3.2 检查Docker版本3.3 检查docker compose 版本四、下载ToDoList镜像…...
基于SpinrgBoot+Vue的医院管理系统-026
一、项目技术栈 Java开发工具:JDK1.8 后端框架:SpringBoot 前端:Vue开发 数据库:MySQL5.7和Navicat管理工具结合 服务器:Tomcat8.5 开发软件:IDEA / Eclipse 是否Maven项目:是 二、功能介绍 (1)…...
如何进行数据安全风险评估总结
一、基于场景进行安全风险评估 一、概述 数据安全风险评估总结(一)描述了数据安全风险评估的相关理论,数据安全应该关注业务流程,以基础安全为基础,以数据生命周期及数据应用场景两个维度为入口进行数据安全风险评估。最后以《信息安全技术 信息安全风险评估规范》为参考,…...
用 npm list -g --depth=0 探索全局包的秘密 ✨
用 npm list -g --depth0 探索全局包的秘密 🚀✨ 嗨,各位开发者朋友们!👋 今天我们要聊一个超实用的小命令——npm list -g --depth0!它就像一个“全局包侦探”🕵️♂️,能帮你快速查出系统中…...
依靠视频设备轨迹回放平台EasyCVR构建视频监控,为幼教连锁园区安全护航
一、项目背景 幼教行业连锁化发展态势越发明显。在此趋势下,幼儿园管理者对于深入了解园内日常教学与生活情况的需求愈发紧迫,将这些数据作为提升管理水平、优化教育服务的重要依据。同时,安装监控系统不仅有效缓解家长对孩子在校安全与生活…...
新闻发稿软文发布投稿选择媒体时几大注意
企业在选择新闻稿发布媒体时,需要综合考虑以下几个关键因素: 1. 匹配媒体定位 企业应根据自身品牌定位和传播目标,选择与之契合的媒体平台。确保新闻稿的内容和风格与媒体的定位高度一致,从而提高稿件被采纳的可能性。 2. 衡量…...
[Scade One] Swan与Scade 6的区别 - signal 特性的移除
signal 特性移除 在 Scade One 引入的Swan中,移除了Scade 6中存在的signal 特性。比如 Scade 6 中的signal声明 sig sig_o;或者signal使用,比如 o sig_o; 在Swan中已经被移除。 不过Swan仍旧保留了对布尔流的emit操作,比如 emit a if c …...
亚马逊推出“站外代购革命“:跨境购物进入全平台整合时代
一、创新功能解析:平台边界消融的购物新范式 亚马逊最新推出的External Product Fulfillment(EPF)服务,正以技术创新重构全球电商格局。这项被称作"代购终结者"的功能具备三大核心突破: 全链路智能化 • 智能…...
Java 常用安全框架的 授权模型 对比分析,涵盖 RBAC、ABAC、ACL、基于权限/角色 等模型,结合框架实现方式、适用场景和优缺点进行详细说明
以下是 Java 常用安全框架的 授权模型 对比分析,涵盖 RBAC、ABAC、ACL、基于权限/角色 等模型,结合框架实现方式、适用场景和优缺点进行详细说明: 1. 授权模型类型与定义 模型名称定义特点RBAC(基于角色的访问控制)通…...
达梦数据库迁移问题总结
问题一、DTS工具运行乱码 开启图形化 [rootlocalhost ~]# xhost #如果命令不存在执行sudo yum install xorg-x11-server-utils xhost: unable to open display "" [rootlocalhost ~]# su - dmdba 上一次登录: 三 4月 9 19:50:44 CST 2025 pts/0 上…...
JS | 函数柯里化
函数柯里化(Currying):将一个接收多个参数函数,转换为一系列只接受一个参数的函数的过程。即 逐个接收参数。 例子: 普通函数: function add(a, b, c) {return a b c; } add(1, 2, 3); // 输出 6柯里化…...
Elasticsearch中的基本全文搜索和过滤
Elasticsearch中的基本全文搜索和过滤 知识点参考: https://www.elastic.co/guide/en/elasticsearch/reference/current/full-text-filter-tutorial.html#full-text-filter-tutorial-range-query 1. 索引设计与映射 多字段类型(Multi-Fields) ÿ…...
蓝桥杯嵌入式第十五届
一、底层 根据它的硬件配置可以看出来这套题目使用到了按键、LED、LCD、输入捕获这几个功能 (1)输入捕获功能 首先在CubeMx里面的配置 题目中说到了我们使用的是PA15和PB4(实际在板子上对应的的是R39和R40),所以我们…...