批量授一种权限给用户程序 plm enovia
set context user DanielDai;
add program LUX_UserAssignment
java
execute immediate
code 'import com.matrixone.apps.domain.util.MqlUtil; import matrix.db.Context; import org.apache.commons.lang.StringUtils; import java.io.*; public class ${CLASSNAME} { public void assignRole(Context context, String[] args) throws Exception{ if(!StringUtils.isNotBlank(args[0])){ System.out.println("exit0:path is null"); return; } String path = args[0]; if(!StringUtils.isNotBlank(args[1])){ System.out.println("exit1:role is null"); return; } String role = args[1]; File file = new File(path); if(!file.exists()){ System.out.println("exist2:file no exist"); return; } InputStream inputStream = new FileInputStream(file); Reader reader = new InputStreamReader(inputStream); BufferedReader bufferedReader = new BufferedReader(reader); String line = null; while((line=bufferedReader.readLine())!=null){ String mql = "temp query bus Person * - where attribute[Email Address]==" + line + " ;"; String res = MqlUtil.mqlCommand(context,mql); if(!StringUtils.isNotBlank(res)){ String[] resS = res.split(","); String personName = resS[1]; mql = "modify Person " + personName + "assign role " + role + " ;"; MqlUtil.mqlCommand(context,mql); } } } } '
;
compile program LUX_UserAssignment force;
execute program LUX_UserAssignment -method assignRole '/opt/plm/MatrixWorkArea/daniel/UserList.csv' 'LUX_CAD_Download' ;
delete program LUX_UserAssignment;
1.UserList.csv 中必须是用户的邮箱列表,因为用户的邮箱唯一,并且区分大小写。
改变 assignRole method 后面的路径和权限名就可以了。
命令中的java 代码 格式化之后:
import com.matrixone.apps.domain.util.MqlUtil;
import matrix.db.Context;
import org.apache.commons.lang.StringUtils;
import java.io.*;
public class LUX_UserAssignment_mxJPO {
public void assignRole(Context context, String[] args) throws Exception{
if(!StringUtils.isNotBlank(args[0])){ System.out.println("exit0:path is null");
return;
}
String path = args[0];
if(!StringUtils.isNotBlank(args[1])){
System.out.println("exit1:role is null");
return;
}
String role = args[1];
File file = new File(path);
if(!file.exists()){
System.out.println("exist2:file does not exist");
return;
}
InputStream inputStream = new FileInputStream(file);
Reader reader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(reader);
String line = null;
while(StringUtils.isNotBlank(line=bufferedReader.readLine())){
String mql = "temp query bus Person * - where \"attribute[Email Address]==" + line + "\" ;";
String res = MqlUtil.mqlCommand(context,mql);
if(!StringUtils.isNotBlank(res)){
System.out.println("Warning:User with email(" + line + ") does not exist!");
continue;
}
if(StringUtils.isNotBlank(res)){
String[] resS = res.split(" ");
String personName = resS[1];
mql = "modify Person " + personName + " assign role " + role + " ;";
MqlUtil.mqlCommand(context,mql);
System.out.println(role + " is assigned to User " + personName + "(" + line + ")" + " successfully!");
}
}
}
}
批量授一种权限给用户程序 plm enovia的更多相关文章
- JAVA基础学习之throws和throw的区别、Java中的四种权限、多线程的使用等(2)
1.throws和throw的区别 throws使用在函数外,是编译时的异常,throw使用在函数内,是运行时的异常 使用方法 public int method(int[] arr) throws ...
- java面向对象中四种权限(private,protected,public,友好型)详解
转自http://blog.csdn.net/a1237871112/article/details/50926975 及http://blog.csdn.net/blackmanren/articl ...
- Gitlab用户在组中有五种权限:Guest、Reporter、Developer、Master、Owner
Gitlab权限管理Gitlab用户在组中有五种权限:Guest.Reporter.Developer.Master.Owner Guest:可以创建issue.发表评论,不能读写版本库Reporte ...
- mybatis 批量update两种方法对比
<!-- 这次用resultmap接收输出结果 --> <select id="findByName" parameterType="string&qu ...
- mybatis批量更新两种方式:1.修改值全部一样 2.修改每条记录值不一样
Mybatis批量更新数据 mybatis批量更新两种方式:1.修改值全部一样 2.修改每条记录值不一样 mybatis批量更新两种方式:1.修改值全部一样 2.修改每条记录值不一样 mybatis批 ...
- Java四种权限修饰符 在创建类中的使用
四种权限修饰符 Java中有四种权限修饰符 public > protected > (default) >private 同一个类(我自己) YES YES YES YES同一个包 ...
- java 基础 四种权限修饰符
/** * Java有四种权限修饰符: * public > protected > (default) > private * 同一个类 YES YES YES YES * 同一个 ...
- 阶段1 语言基础+高级_1-3-Java语言高级_02-继承与多态_第6节 权限修饰符_6_四种权限修饰符
四种权限修饰符.从大到小 纵向再分成四种情况 同一个类 同一个类里面.private方式,可以访问到本类里面的 num成员变量 前面不写修饰符也能访问到 (default)就是不写的这种情况 受保护的 ...
- Java 四种权限修饰符
Java 四种权限修饰符访问权限 public protected (default) private 同一个类(我自己) yes yes yes yes 同一包(我邻居) yes yes yes n ...
随机推荐
- jieba库的使用
jieba库的使用 jeiba库是一款很优秀的用于中文分词的第三方库,它通过一个汉词词典来确定汉字之间的关联概率,将概率较大的组成分词. 精准模式 把文本精准的分割开来,不存在冗余单词. jieba. ...
- nginx日志切割脚本shell
nginx-log-rotate.sh: #!/bin/bash#---------------------------------------------# Comment:Used for rot ...
- BJSV-P-003高清智能卡口系统
高清智能卡口系统 捕获率99%,车牌识别率98% ■ 道路安装示意图 ■ 系统结构 ■ 抓拍实例 北京太速科技有限公司在线客服:QQ:448468544 淘宝网站:orihard.tao ...
- ffmpeg音频文件转换之使用stdin/stdout或BytesIO对象输入输出
最近在搞小程序录音,然后使用百度接口做语音识别. 小程序目前仅支持mp3和aac编码格式.虽然百度接口提供的m4a格式支持能直接识别小程序的录音文件,但由于自己还有其他一系列需求(比如直接读取数据,根 ...
- MongoDB 导入导出以及数据库备份
-------------------MongoDB数据导入与导出------------------- 1.导出工具:mongoexport 1.1.概念: mongoDB中的 ...
- maven仓库mirrors
<mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> & ...
- Component series.liquidFill not exists. Load it first.
vue 项目中使用水波球报错Component series.liquidFill not exists. Load it first. 解决办法:安装 echarts-liquidfill npm ...
- Windows Server服务器之Linux server与windows server的区别
Linux server与windows server的区别用linux做server,相对于windows server有什么优势? 首先,平均故障时间少,只要配置和使用得当,linux的平均故障( ...
- SPOJ - FTOUR2 (点分治+树状数组)
题目:https://vjudge.net/contest/307753#problem/I 题意:有一颗树,上面有白色黑色点,每个点上有一个权值,权值可以为负,现在我要求一条路径,权值和最大,这条路 ...
- [LightOJ1070]Algebraic Problem
题目:Algebraic Problem 链接:https://vjudge.net/problem/LightOJ-1070 分析: 1)$ a^n+b^n = ( a^{n-1}+b^{n-1} ...