自定义命名服务
预设
当用户使用“保存”和“从 Creo 上传”操作创建 CAD 文档时,预设委派可用于提供 CAD 文档名称和编号的值。
* 
命名服务仅适用于上传操作。
系统为命名策略和自定义所使用的优先顺序如下:
名称:
a. 自定义:命名服务自定义。
b. PTC_COMMON_NAME:通过 Creo Parametric“文件” > “新建”窗口显式分配的公用名称。
c. 参数驱动:名称参数 (“操作” > “上传操作” > “上传” > “命名参数”= <某字符串参数>)。
d. 名称驱动:文件名 (只有在基于“文件名”[CAD 名称] 分配“名称”时,首选项“操作” > “上传操作” > “上传” > “在名称中去除文件扩展名”才会生效)
编号:
a. 自定义:命名服务自定义。
b. 自动编号:如果首选项“操作” > “上传操作” > “若未设置编号,上传时使用编号的默认值”设置为“文件名不与编号同步”时,则使用 OIR 生成编号。
c. 参数驱动:编号参数 (“操作” > “上传操作” > “上传” > “编号参数”)
d. 名称驱动:只有在基于“文件名”[CAD 名称] 分配“编号”时,首选项“操作” > “上传操作” > “上传” > “在编号中去除文件扩展名”才会生效。
* 
在配置 OIR 时,系统会对文件名进行自动编号。
有关命名和编号策略的详细信息,请参阅受策略管理的命名和编号
通过委派实现的自定义命名服务
命名服务通过 Windchill 服务委派机制,可创建优先于任何预设行为的 Java 委派,以提供 CAD 文档名称或编号的值。
要自定义命名服务:
1. 创建一个实现接口 EPMDocumentNamingDelegate 的 Java 类。接口定义如下:
package com.ptc.windchill.uwgm.proesrv.c11n;
public interface EPMDocumentNamingDelegate
{
public void validateDocumentIdentifier(DocIdentifier
docIdentifier);
}
类 DocIdentifier 的定义如下。
package com.ptc.windchill.uwgm.proesrv.c11n;
import java.util.HashMap;
public class DocIdentifier
{
{
private String m_modelName;
private String m_docName;
private String m_docNumber;
private HashMap m_parameters;
}
public DocIdentifier(String modelName, String
docName, String docNumber, HashMap params)
{
m_modelName = modelName;
m_docName= docName;
m_docNumber= docNumber;
m_parameters= params;
}
/** get the CAD Name for the model **/

public String getModelName()
{
return m_modelName;
}
/** get the EPMDocument name for the model **/

public String getDocName()
{
return m_docName;
}
/** set the EPMDocument name for the model **/
public void setDocName(String docname)
{
m_docName = docname;
}
/** set the EPMDocument number for the model **/
public void setDocNumber(String docnumber)
{
m_docNumber = docnumber;
}
/** get the EPMDocument number for the model **/
public String getDocNumber()
{
return m_docNumber;
}
/** get the Pro/E designated parameters for the model. These are
name-value pairs indexed by the name **/
public HashMap getParameters()
{
return m_parameters;
}
}
2. 在新类中,按以下方法实现对 EPMDocument 命名/编号的业务逻辑:
public void validateDocumentIdentifier(DocIdentifier docIdentifier)
DocumentIdentifier 对象具有将由上传服务创建的 EPMDocument 的名称和编号信息。
使用 DocIdentifier.getModelName() 获取此 DocIdentifier 对象所表示的 EPMDocument 的 CAD 名称。
Creo Parametric 指定的参数可用于设置 EPMDocument 编号/命名。
使用 DocIdentifier.getParameters() 获取关联参数。
使用 DocIdentifier 的 "set" 方法来设置新名称/编号值。如果可行,上传服务会使用这些建议。
3. 编辑 site.xconf 文件 (位于 <Windchill> 中) 来添加以下特性,以指出服务器上自定义服务的可用性:
<Service context="default" name="com.ptc.windchill.uwgm.proesrv.c11n.EPMDocumentNamingDelegate" targetFile="codebase/service.properties">
<Option cardinality="singleton" requestor="wt.epm.EPMDocument" serviceClass="com.ptc.windchill.uwgm.proesrv.c11n.EPMDefaultDocument NamingDelegate"/>
</Service>
然后,使用 xconfmanager 工具将变更应用于 service.properties 文件 (运行 -xconfmanager p)。
使用类路径代替 serviceClass 的值 (即,使用类路径替换 "com.ptc.windchill.uwgm.proesrv.c11n.EPMDefaultDocumentNamingDelegate")。
4. 重新启动方法服务器。
这对您有帮助吗?