guru@windchillguru.com's Profile

2676
Points

Questions
16

Answers
28

  • Asked on September 9, 2019 in Windchill PLM.

    Sorry for the late response, there is no easy way to get the complete ACL for an object, the best way is to write a report using QueryBuilder and get all the ACLs.

    • 307 views
    • 1 answers
    • 0 votes
  • Asked on September 9, 2019 in Windchill PLM.
    • The principal string representation of references in Windchill :
    <class>:<key> : string representation of an ObjectIdentifier.
    OR:<class>:<key> : string representation of an ObjectReference.
    VR:<class>:<key> : string representation of an VersionReference.
    • Snippet code to dereference these strings :
    import wt.fc.ObjectIdentifier;
    import wt.fc.PersistenceHelper;
    import wt.fc.ReferenceFactory;
    import wt.fc.WTReference;

    /* ObjectIdentifier string to WTPart */
    ObjectIdentifier oid = ObjectIdentifier.newObjectIdentifier(“wt.part.WTPart:20154“);
    WTPart part = (WTPart) PersistenceHelper.manager.refresh(oid);
    /* ObjectReference / VersionReference string to WTPart */
    ReferenceFactory rf = new ReferenceFactory();
    WTReference ref = (WTReference) rf.getReference(“OR:wt.part.WTPart:20154“);
    WTPartpart = (WTPart) ref.getObject();
    ReferenceFactory rf = new ReferenceFactory();
    WTReference ref = (WTReference) rf.getReference(“VR:wt.part.WTPart:20153“);
    WTPart part = (WTPart) ref.getObject();
    • 39 views
    • 1 answers
    • 0 votes
  • Asked on April 9, 2019 in Windchill PLM.

    Unfortunately, Windchill has no API’s to change the Creator once the object is created, but you can change the session user before the object is persisted, then the persistence layer will consider the user from Session.

    • 561 views
    • 1 answers
    • 0 votes
  • Asked on April 4, 2019 in Windchill PLM.

    Hello,

     

    As per the windchill architecture, WFBlock’s can contain one or more activities and these activities can be general AssignedActivity or AdhocActivity, so in order to get the access for AdhocActivities you need to first provide “Read” access to WFBlock and then if you have provided “Read” access to AdhocSctivity then the user will not get the above-mentioned error.

    Hope this helps.

    • 334 views
    • 1 answers
    • 0 votes
  • Asked on February 12, 2019 in Windchill PLM.

    There is no Supported API’s to perform Operations involving sharing objects to project link.

    below is a sample that can be used.

    wt.inf.sharing.DataSharingHelper.service.createShares() 
    public WTCollection createShares(WTCollection objsToShare, WTContainerRef to_container_ref, Folder to_folder, ShareKind kind, State state, boolean is_shortcut) throws WTException

    Example Usage:

    ObjectIdentifier oid = null;
    try {
      oid = ObjectIdentifier.newObjectIdentifier("wt.part.WTPart:XXXXX");
      wt.part.WTPart record = (wt.part.WTPart) PersistenceHelper.manager.refresh(oid);
      oid = ObjectIdentifier.newObjectIdentifier("wt.projmgmt.admin.Project2:XXXX");
      WTContainerRef projRef = WTContainerRef.newWTContainerRef(oid);
      WTSet objs = new WTHashSet(1, CollectionsHelper.OBJECT_IDENTIFIER);
      objs.add(record);
      WTCollection share = DataSharingHelper.service.createShares(objs, projRef, null, ShareKind.OBJECT, null, false);
    } catch(WTException e) { 
    // TODO Auto-generated catch block                   
    e.printStackTrace();            
    }

     

    • 536 views
    • 1 answers
    • 0 votes
  • Asked on February 12, 2019 in Windchill PLM.
    • Use the Search-Index webject in conjunction with Search-Objects by sending to the later the ufids returned by the former for filtering
    • Example:
    <?xml version="1.0" standalone="yes"?>
    <%@taglib uri="http://www.ptc.com/infoengine/taglib/core" prefix="ie"%>
    <%@page access="internal|http"%>
    
    
       <% String searchTypes="wt.doc.WTDocument";%>
       <% String searchAttribs="number,name,versionInfo.identifier.versionId,iterationInfo.identifier.iterationId,containerName";%>
       <%
          Integer MAX_RESULTS = 30;
          Integer start = 1;
          Integer count = MAX_RESULTS;
          if(count.intValue() <= 0) count = null;
          
          String keyword = (String)getParam("keyword");
          String ufids = "";
          if(!(keyword.equals("*") || keyword.equals("%") || keyword.equals("")))
          {
       %>
             <ie:webject name="Indexed-Search" type="OBJ">
                <ie:param name="INSTANCE"      data="${@FORM[]supporting-adapter[*]}" valueSeparator=";" delim=";" default="ts.ptc.wncx24.Windchill"/>
                <ie:param name="KEYWORD"       data="${@FORM[]keyword[]}"/>
                <ie:param name="LIBRARIES"      data="${@FORM[]LIBRARIES[]}" delim=","/>
                <ie:param name="ATTRIBUTE_TYPE_CONTEXT" data="${@FORM[]attributeTypeContext[*]}" default="wt.fc.Persistable"/>
                <ie:param name="AND_OR_OPERATOR" data="SIMPLEALL" />
                <ie:param name="TYPE"         data="${@FORM[]SearchTypes[]}" delim="," default="<%=searchTypes%>"/>
                <ie:param name="GROUP_FORM"    data="@FORM"/>
                <ie:param name="FILTER_ACCESS" data="true" />
                <ie:param name="group_out" data="index_search"/>
                <ie:param name="UNFORMATTED" data ="java.sql.Timestamp" />
             </ie:webject>
          <%
             Group index_results = getGroup("index_search");
             int idx_count = index_results.getElementCount();
             for(int i = 0; i < idx_count; i++)
             {
                String ufid = (String)index_results.getElementAt(i).getValue("obid");
                if(ufid != null && ufid.length() > 0)
                {
                   if(ufids.length() > 0) ufids += ",";
                   ufids += ufid;
                }
             }
          }
       %>
       <ie:webject name="Search-Objects" type="OBJ">
         <ie:param name="INSTANCE" data="${@FORM[]supporting-adapter[*]}" valueSeparator=";" delim=";" default="windchill"/>
         <ie:param name="ATTRIBUTE" data="${@FORM[]SearchAttributes[]}" delim="," default="<%=searchAttribs%>"/>
         <ie:param name="ATTRIBUTE_TYPE_CONTEXT" data="${@FORM[]attributeTypeContext[*]}" default="wt.fc.Persistable"/>
         <ie:param name="TYPE" data="${@FORM[]SearchTypes[]}" delim="," default="<%=searchTypes%>"/>
         <% if(ufids.length() == 0) { %>
          <ie:param name="KEYWORD" data="${@FORM[]keyword[]}"/>
         <% } %>
         <ie:param name="PAGE_OFFSET" data="<%=start%>" />
         <% if (count != null ) { %><ie:param name="PAGE_COUNT" data="<%=count+1%>" /><% } %>
         <ie:param name="WHERE" data="(${@FORM[]AttributeFilter[]})" />
         <ie:param name="GROUP_FORM" data="@FORM"/>
         <ie:param name="group_out" data="output"/>
         <ie:param name="FORMAT" data="true"/>
         <ie:param name="INCLUDE_DESCRIPTORS" data="false"/>
         <ie:param name="UNFORMATTED" data ="java.sql.Timestamp" />
         <% if(ufids.length() > 0) { %><ie:param name="OBJECT_REF" data="<%=ufids%>" delim="," /><% } %>
                     <ie:param name="SORTBY" data="${@FORM[]SortBy[*]}" delim="," default="name" />
                     <ie:param name="SORTED" data="${@FORM[]SortDirection[]}" default="ASC" />
    
       </ie:webject>

     

    • 730 views
    • 1 answers
    • 0 votes
  •  

     

    String parentPartNumber;
    String ParentPartName;
    String partNumber;
    String PartName;
    
    QuerySpec spec = new QuerySpec();
    
    spec.setAdvancedQueryEnabled(true);
    
    int WTPartMasterIndex = spec.addClassList(wt.part.WTPartMaster.class, true);
    
    int WTPartUsageLinkIndex = spec.addClassList(wt.part.WTPartUsageLink.class, true);
    
    int partIndex = spec.appendClassList(wt.part.WTPart.class, true);
    
    SearchCondition where = new SearchCondition(new ClassAttribute(wt.part.WTPartMaster.class,
      "thePersistInfo.theObjectIdentifier.id"), SearchCondition.EQUAL,
     new ClassAttribute(wt.part.WTPartUsageLink.class, "roleBObjectRef.key.id"));
    
    spec.appendWhere(where, new int[] {
     WTPartMasterIndex,
     WTPartUsageLinkIndex
    });
    
    spec.appendAnd();
    
    SearchCondition where2 = new SearchCondition(new ClassAttribute(wt.part.WTPartUsageLink.class,
      "roleAObjectRef.key.id"), SearchCondition.EQUAL,
     new ClassAttribute(wt.part.WTPart.class, "thePersistInfo.theObjectIdentifier.id"));
    
    spec.appendWhere(where2, new int[] {
     WTPartUsageLinkIndex,
     partIndex
    });
    
    spec.appendAnd();
    
    spec.appendWhere(new SearchCondition(wt.part.WTPart.class, "checkoutInfo.state", SearchCondition.NOT_EQUAL, "wrk"), partIndex);
    spec.appendAnd();
    spec.appendWhere(new SearchCondition(wt.part.WTPart.class, "iterationInfo.latest", "TRUE"), partIndex);
    spec.appendAnd();
    spec.appendWhere(new SearchCondition(wt.part.WTPart.class, wt.part.WTPart.LIFE_CYCLE_STATE, SearchCondition.NOT_EQUAL, "CANCELLED"), partIndex);
    if (parentPartNumber != null && parentPartNumber.trim().length() != 0) {
     spec.appendAnd();
     spec.appendWhere(new SearchCondition(wt.part.WTPart.class,
      "master>number", SearchCondition.LIKE, parentPartNumber + "%"), partIndex);
    }
    
    if (ParentPartName != null && ParentPartName.trim().length() != 0) {
     spec.appendAnd();
     spec.appendWhere(new SearchCondition(wt.part.WTPart.class,
      "master>name", SearchCondition.LIKE, ParentPartName + "%"), partIndex);
    }
    
    if (partNumber != null && partNumber.trim().length() != 0) {
     spec.appendAnd();
     spec.appendWhere(new SearchCondition(wt.part.WTPartMaster.class,
      "number", SearchCondition.LIKE, partNumber + "%"), WTPartMasterIndex);
    }
    
    if (PartName != null && PartName.trim().length() != 0) {
     spec.appendAnd();
     spec.appendWhere(new SearchCondition(wt.part.WTPartMaster.class,
      "name", SearchCondition.LIKE, PartName + "%"), WTPartMasterIndex);
    
    }
    QueryResult result = PersistenceHelper.manager.find(spec);
    while (result.hasMoreElements()) {
     wt.fc.Persistable persistables[] = (wt.fc.Persistable[]) result.nextElement();
     wt.part.WTPart parentPart = (wt.part.WTPart) persistables[partIndex];
     wt.part.WTPartUsageLink usageLink = (wt.part.WTPartUsageLink) persistables[WTPartUsageLinkIndex];
     wt.part.WTPartMaster subPartMaster = (wt.part.WTPartMaster) persistables[WTPartMasterIndex];
    }

     

    • 759 views
    • 1 answers
    • 0 votes
  • public static void sendEmail( String cSVfileName, String fileName2) throws WTException, IOException {
    
      String thePath = null;
      Properties prop = new Properties();
      FileInputStream input = null;
      String theWTCodebaseHome = WTProperties.getLocalProperties().getProperty("wt.codebase.location");
      theWTCodebaseHome = theWTCodebaseHome.replace('\\', '/');
      thePath = theWTCodebaseHome + "/ext/email.properties";
      input = new FileInputStream(thePath);
      prop.load(input);
      String to  = prop.getProperty("EMAIL.TO", "123@test.com").trim();
      // Sender's email ID needs to be mentioned
      String from = prop.getProperty("EMAIL.FROM", "postMaster@abc.com").trim();
      // Assuming you are sending email through relay.jangosmtp.net
      String host = prop.getProperty("EMAIL.HOST", "localhost").trim();
      Date date = new Date();
      SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss");
      sdf.setTimeZone(TimeZone.getTimeZone("America/Chicago"));
      String strDate = sdf.format(date);
      Properties props = new Properties();
      props.put("mail.smtp.auth", "false");
      props.put("mail.smtp.starttls.enable", "false");
      props.put("mail.smtp.host", host);
      props.put("mail.smtp.port", "25");
      // Get the Session object.
      Session session = Session.getInstance(props);
      try {
      // Create a default MimeMessage object.
      Message message = new MimeMessage(session);
      // Set From: header field of the header.
      message.setFrom(new InternetAddress(from));
      // Set To: header field of the header.
      message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
      // Set Subject: header field
      message.setSubject("EMAIL SUBJECT - " + strDate);
      // Create the message part
      BodyPart messageBodyPart = new MimeBodyPart();
      // Now set the actual message
      messageBodyPart.setText("Please see the attached files.");
      // Create a multipar message
      Multipart multipart = new MimeMultipart();
      // Set text message part
      multipart.addBodyPart(messageBodyPart);
      // Part two is attachment
      messageBodyPart = new MimeBodyPart();
      boolean zipExist = false;
      boolean csvExist = false;
      File tempFile = new File(fileName2);
      if (tempFile.exists()) {
      System.out.println(fileName2);
      DataSource source = new FileDataSource(fileName2);
      messageBodyPart.setDataHandler(new DataHandler(source));
      messageBodyPart.setFileName(strDate + ".zip");
      multipart.addBodyPart(messageBodyPart);
      zipExist = true;
      }
      tempFile = new File(cSVfileName);
      if (tempFile.exists()) {
      messageBodyPart = new MimeBodyPart();
      // String filename = "D:\\temp\\test.zip";
      System.out.println(cSVfileName);
      cSVfileName = createXLSFile(cSVfileName);
      DataSource source = new FileDataSource(cSVfileName);
      messageBodyPart.setDataHandler(new DataHandler(source));
      messageBodyPart.setFileName(strDate + ".xls");
      multipart.addBodyPart(messageBodyPart);
      csvExist = true;
      }
      // Send the complete message parts
      message.setContent(multipart);
      Address[] allrec = message.getAllRecipients();
      for (Address ad : allrec) {
      System.out.println(ad);
      }
      // Send message
      Transport.send(message);
      System.out.println("Sent message successfully....");
      } catch (MessagingException e) {
      throw new RuntimeException(e);
      }
      }

     

    Or If you would like to use Windchill API’s to send an email attaching windchill objects ( not external file attachments ) use below code snippet.

    wt.fc.ObjectIdentifier oid = wt.fc.ObjectIdentifier.newObjectIdentifier("wt.part.WTPart:xxxxx");
    wt.part.WTPart wtpart = (wt.part.WTPart)PersistenceHelper.manager.refresh(oid);
    EMailMessage localEMailMessage=EMailMessage.newEMailMessage();
    localEMailMessage.setOriginator(wtpart.getModifier());
    localEMailMessage.addRecipient(wtpart.getModifier()); 
    localEMailMessage.setSubject("ext.customization.CustomResource","EMAIL_SUBJECT",new String[]{wtpart.getName()}); 
    localEMailMessage.addPart("ext.customization.CustomResource","EMAIL_SUBJECT",new String[]{retMsg},"text/plain");
    localEMailMessage.send(true);

     

     

    • 733 views
    • 1 answers
    • 0 votes
  • Asked on January 3, 2019 in Windchill PLM.
    • Definitions are stored:
    BooleanDefinition 
    FloatDefinition  
    IntegerDefinition 
    RatioDefinition 
    ReferenceDefinition 
    StringDefinition
    TimestampDefinition 
    UnitDefinition
    URLDefinition
    • Values are stored:
    BooleanValue 
    FloatValue  
    IntegerValue 
    RatioValue 
    ReferenceValue 
    StringValue
    TimestampValue 
    UnitValue
    URLValue
    • 875 views
    • 1 answers
    • 0 votes
  • Asked on November 5, 2018 in Windchill PLM.

    Follow Below Steps to Deploy Custom Web Application in Windchill Tomcat.

    • Copy the war to a directory say /app01/windchill11/Windchill/tomcat/webapps/sample
    • Open a Windchill shell run the command, navigate to /app01/windchill11/Windchill/tomcat and run the below command, appName is the what you use after server name to access the application. This will install the web app on Windchill Tomcat
    ant -f config.xml installWebApp -DappName=sample -DdocBase=/app01/windchill11/Windchill/tomcat/webapps/sample
    • Now you have two options either to enable direct HTTP access on tomcat to access the app or use web server directives direct the traffic to tomcat. if you want to enable
      • direct access add below line to /app01/windchill11/Windchill/tomcat/conf/server.xml.default
      • <Connector port="8080" protocol="HTTP/1.1"  connectionTimeout="20000" redirectPort="8443" />

         

    • Now restart Windchill and access the page – http://localhost:8080/sample
    • 690 views
    • 1 answers
    • 0 votes