首页 > 其他分享 >Winchill分类更新

Winchill分类更新

时间:2023-05-16 16:45:43浏览次数:35  
标签:core 分类 ptc 更新 Winchill lwc import null com

 

package ext.huyx.integration.classification.test;

import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

import com.ptc.core.lwc.client.util.PropertyDefinitionHelper;
import com.ptc.core.lwc.common.AttributeTemplateFlavor;
import com.ptc.core.lwc.common.view.PropertyDefinitionReadView;
import com.ptc.core.lwc.common.view.PropertyValueReadView;
import com.ptc.core.lwc.common.view.PropertyValueWriteView;
import com.ptc.core.lwc.common.view.TypeDefinitionReadView;
import com.ptc.core.lwc.common.view.TypeDefinitionWriteView;
import com.ptc.core.lwc.server.LWCStructEnumAttTemplate;
import com.ptc.core.lwc.server.TypeDefinitionServiceHelper;
import com.ptc.core.lwc.server.cache.TypeDefinitionManager;

import ext.huyx.integration.classification.util.ClassificationUtil;
import wt.fc.ObjectIdentifier;
import wt.httpgw.GatewayAuthenticator;
import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;

public class CTest implements RemoteAccess {

	public static void main(String[] args) throws RemoteException, InvocationTargetException {
		RemoteMethodServer rms = RemoteMethodServer.getDefault();
		GatewayAuthenticator auth = new GatewayAuthenticator();
		auth.setRemoteUser("wcadmin");
		rms.setAuthenticator(auth);
		rms.invoke("test2", CTest.class.getName(), null, null, null);
	}
	public static void test2() throws Exception {
		String internalName = "relay11";// 节点内部值
		Map<Locale, String> displayNameMap = new HashMap<Locale, String>();
		displayNameMap.put(Locale.CHINA, "继电器");
		displayNameMap.put(Locale.ENGLISH, "Relay");
		displayNameMap.put(Locale.US, "Relay");
		Map<String, Object> values = new HashMap<String, Object>();
		values.put("keywords", "关键字");
		values.put("displayName", displayNameMap);
		values.put("description", "说明");
		values.put("instantiable", "true");
		values.put("sort_order", "1");

		LWCStructEnumAttTemplate lwc = ClassificationUtil.getClassificationByInternalName(internalName);//获取分类节点对象的api
		TypeDefinitionReadView typeDefReadView = null;
		if (lwc != null) {
			ObjectIdentifier lwcOid = lwc.getPersistInfo().getObjectIdentifier();
			typeDefReadView = TypeDefinitionManager.getTypeDefinitionManagerInstance().getTypeDefView(AttributeTemplateFlavor.LWCSTRUCT, lwcOid.getId());
		}
		TypeDefinitionWriteView typeDefWriteView = typeDefReadView.getWritableView();
		Set<PropertyDefinitionReadView> propertyDefs = TypeDefinitionServiceHelper.service
				.getAllPropertyDefViews("com.ptc.core.lwc.server.LWCStructEnumAttTemplate", typeDefReadView.getReadViewIdentifier());
		for (PropertyDefinitionReadView propertyDefView : propertyDefs) {
			if (propertyDefView.isHidden() || propertyDefView.isContentHolder()) {
				continue;
			}
			String propertyDefName = propertyDefView.getName();
			PropertyValueReadView currentPropertyValue = typeDefReadView.getPropertyValueByName(propertyDefName);
			PropertyValueWriteView propValueWriteView = (currentPropertyValue == null) ? null : currentPropertyValue.getWritableView();
			Object value = values.get(propertyDefName);
			String newPropertyValue = "";
			Map<Locale, String> localMap = null;
			if (value == null) {
				newPropertyValue = "";
			} else if (value instanceof String) {
				newPropertyValue = values.get(propertyDefName).toString();
			} else if (value instanceof Map) {
				localMap = (Map<Locale, String>) value;
				newPropertyValue = localMap.get(Locale.CHINA);
			}
			boolean createNewValue = PropertyDefinitionHelper.updatePropertyValue(propertyDefView, null, propValueWriteView, newPropertyValue, localMap,
					false);
			if (createNewValue) {
				propValueWriteView = new PropertyValueWriteView(null, propertyDefView, newPropertyValue, localMap, null, false, null, false);
			}
			if (propValueWriteView != null && values.get(propertyDefName) != null) {
				typeDefWriteView.setProperty(propValueWriteView);
			}
		}
		typeDefReadView = TypeDefinitionServiceHelper.service.updateTypeDef(typeDefWriteView);
	}
}

 

标签:core,分类,ptc,更新,Winchill,lwc,import,null,com
From: https://www.cnblogs.com/huyax/p/17406087.html

相关文章

  • Allegro PCB封装库(分类、命名很规范,已验证) 该PCB库特点一:类型
    AllegroPCB封装库(分类、命名很规范,已验证)该PCB库特点一:类型齐全,包含有阻容感分立元器件;SOIC(SO,SOP,SSOP,TSOP,TSSOP);QFN;QFP(PQFP,SQFP,CQFP);PLCC;BGA及常用连接器等PCB封装,共400多个的库文件。该PCB库特点二:库文件命名规范,例如BGA类型的PCB封装命名为:BGA+引脚数+PIN间距+主体......
  • [学习笔记] Mplus实现(多分类)Logistic回归
    [学习笔记]Mplus实现(多分类)Logistic回归废话少说版Logistic回归是适用于用连续变量或类别变量作为预测变量,类别变量作为结果变量的回归模型。对结果变量采取logit变换,若结果变量为二分变量,变换形式为\(ln\frac{P}{1-P}\),若结果变量为多分类变量,变换形式为\(ln\frac{P(A)}......
  • 使用xml更新solr索引
    使用xml更新solr索引Solr接受xml格式数据更新、提交、修改索引。 更新的Schema不要混淆SCHEMA.XMLadd/replacedocuments SimpleExample:<!--[if!supportLists]-->·<!--[endif]--><add><!--[if!supportLists]-->·<!--[endif]--><doc><!--[......
  • 深度学习---视觉领域分类
    深度学习在视觉领域分类一、图像分类图像分类是指将数字图像自动分类到不同的预先定义类别中。二、目标检测目标检测是指在图像或视频中自动识别和定位特定物体的任务。与图像分类不同,它不仅需要确定物体的类别,还需要找出物体在图像中的位置。按照框分类又可以分为平行框检......
  • 鲸鱼优化算法WOA优化CNN的隐含层个数和学习率做多特征输入单输出的二分类及多分类模型
    鲸鱼优化算法WOA优化CNN的隐含层个数和学习率做多特征输入单输出的二分类及多分类模型。程序内注释详细,直接替换数据就可以用。程序语言为matlab。程序可出分类效果图,迭代优化图,混淆矩阵图具体效果如下所示。PS:以下效果图为测试数据的效果图,主要目的是为了显示程序运行可以出的结......
  • 深度神经网络(DNN)做多特征输入单输出的二分类及多分类模型
    深度神经网络(DNN)做多特征输入单输出的二分类及多分类模型。程序内注释详细,直接替换数据就可以用。程序语言为matlab。程序可出分类效果图,迭代优化图,混淆矩阵图具体效果如下所示。。PS:以下效果图为测试数据的效果图,主要目的是为了显示程序运行可以出的结果图,具体预测效果以个人......
  • 算数优化算法AOA优化LSTM做多特征输入单输出的二分类及多分类模型。
    算数优化算法AOA优化LSTM做多特征输入单输出的二分类及多分类模型。程序内注释详细,直接替换数据就可以用。程序语言为matlab。程序可出分类效果图,迭代优化图,混淆矩阵图具体效果如下所示。。PS:以下效果图为测试数据的效果图,主要目的是为了显示程序运行可以出的结果图,具体预测效果......
  • 苍鹰优化算法NGO优化BP神经网络的软值和阈值参数做多输入单输出的分类建模。
    苍鹰优化算法NGO优化BP神经网络的软值和阈值参数做多输入单输出的分类建模。程序内注释详细直接替换数据就可以使用。程序语言为matlab。程序直接运行可以出分类图,迭代优化图,ROC图。ID:4335687662172622......
  • 基于DBN的二分类和多分类的分类预测模型。 程序语言为matlab。
    基于DBN的二分类和多分类的分类预测模型。程序语言为matlab。直接替换excel数据就可以使用。。ID:8735682410333583......
  • 利用无限潜在特征选择ILFS算法对分类特征变量做特征重要性排序,实现特征选择。
    利用无限潜在特征选择ILFS算法对分类特征变量做特征重要性排序,实现特征选择。通过重要性排序图,选择重要的特征变量,以期实现数据降维的目的。程序直接替换数据就可以用,程序内有注释,方便学习和使用。程序语言为matlab。ID:3530682564934266......