CoCreate User Forum  

Go Back   CoCreate User Forum > Applications > Data Management
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Rating: Thread Rating: 18 votes, 5.00 average. Display Modes
  #1  
Old 11-16-2012, 08:16 AM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
My first Java - camel case to upper case

I'm pretty excited with my first Java snippet that helps our efficiency when saving new models to ModelManager, and thought I'd share. I'm sure I've got a lot of scenarios I need to test and troubleshoot, but here's my little script that takes the model description from Modeling and converts the camel case description (ThisIsATestCylinder.01) into a more appropriate ModelManager description (THIS IS A TEST CYLINDER).

Code:
package com.zetec.dm.biz;

import com.osm.biz.WMSession;
import com.osm.dm.biz.DMModel3D;
import com.osm.exception.WMException;

public class ZetecDMModel3D extends DMModel3D {

    public ZetecDMModel3D(WMSession theSession, int theHandle) throws WMException {
        super(theSession, theHandle);

        super.setDescription(originID);
    }

    @Override
    public void setDescription(String description) throws WMException {
        super.setDescription(description.replaceAll(
      String.format("%s|%s|%s",
         "(?<=[A-Z])(?=[A-Z][a-z])",
         "(?<=[^A-Z])(?=[A-Z])",
         "(?<=[A-Za-z])(?=[^A-Za-z])"), " ").toUpperCase()
       );
    }
}
Thanks to mbDataRefresh for the mentorship, and to http://stackoverflow.com/questions/2...-names-in-java for the regexp
Attached Thumbnails
Click image for larger version

Name:	CamelCaseModelToGoodMMDesc.PNG
Views:	536
Size:	38.3 KB
ID:	1874  

Last edited by gmatelich; 01-03-2013 at 03:31 PM.
Reply With Quote
  #2  
Old 01-03-2013, 03:26 PM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
Re: My first Java - camel case to upper case

Apparently there is some flaw in my implementation that causes some strange behavior in my Search and Recent view windows. The Description field for Models doesn't fill in, but it does for Parts and Drawings.

The really strange part is that if I expand the history folder, the Description field will update.

Here is how I call the Java in my .xml
Code:
<Class extends="DMModel, DMReleaseProcess">
    <Name>MODEL_3D</Name>
    <BusinessObjectClass>com.zetec.dm.biz.ZetecDMModel3D</BusinessObjectClass>
Can anyone see what I'm doing wrong, and help set me straight?

In case it matters, here's the whole .xml:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<WMConfig>
	<WMServerInfo>
...</WMServerInfo>

	<ClassDefs>
		<Class extends="DMMasterdata, DMReleaseProcess">
			<Name>MASTERDATA</Name>
			<Attribute>
				NAME
				<Visible>true</Visible>
				<DisplayName>Part Number</DisplayName>
				<AttributeEditorClass>com.osm.datamgmt.editor.NumberGeneratorEditor</AttributeEditorClass>
				<CustomAttribute>false</CustomAttribute>
				<IncludeInLayoutManager>true</IncludeInLayoutManager>
				<EnabledDuringSave>false</EnabledDuringSave>
				<Index>1</Index>
			</Attribute>
			<Attribute> DESCRIPTION
				<Index>2</Index>
			</Attribute>
			<Attribute> TYPE
				<Index>3</Index>
			</Attribute>
			<Attribute> PROJECT_NO
				<Index>4</Index>
			</Attribute>
			<Attribute> SIMILAR
				<Index>5</Index>
			</Attribute>
			<Attribute> MATERIAL
				<Index>6</Index>
			</Attribute>
			<Attribute> DESCRIPTION2
				<Index>7</Index>
			</Attribute>
		</Class>

		<Class extends="DMModel, DMReleaseProcess">
			<Name>LIBRARY_3D</Name>
			<Attribute>
				NAME
				<Visible>true</Visible>
				<DisplayName>Part Number</DisplayName>
				<Index>1</Index>
			</Attribute>
			<Attribute> VERSION
				<Index>2</Index>
			</Attribute>
			<Attribute> DESCRIPTION
				<Index>3</Index>
			</Attribute>
			<Attribute> TYPE
				<Index>4</Index>
			</Attribute>
			<Attribute> MATERIAL
				<Index>5</Index>
			</Attribute>
			<Attribute> DESCRIPTION2
				<Index>6</Index>
			</Attribute>
		</Class>

		<Class extends="DMModel, DMReleaseProcess">
			<Name>MODEL_3D</Name>
			<BusinessObjectClass>com.zetec.dm.biz.ZetecDMModel3D</BusinessObjectClass>
			<NameFormat>%Name%: [%Version%] %State%</NameFormat>
			<Attribute>
				NAME
				<Visible>true</Visible>
				<DisplayName>Part Number</DisplayName>
				<RollingNumberGeneratorName>New Number Generator</RollingNumberGeneratorName>
				<BusinessObjectClass>com.osm.datamgmt.biz.RollingNumberGenerator</BusinessObjectClass>
				<AttributeEditorClass>com.osm.datamgmt.editor.NumberGeneratorEditor</AttributeEditorClass>
				<CustomAttribute>false</CustomAttribute>
				<IncludeInLayoutManager>true</IncludeInLayoutManager>
				<Index>1</Index>
			</Attribute>
			<Attribute>
				SIMILAR
				<IsPartAttribute>true</IsPartAttribute>
				<Visible>true</Visible>
				<DisplayName>Similar Part</DisplayName>
				<SourceAttributeName>SIMILAR</SourceAttributeName>
				<TargetAttributeName>SIMILAR</TargetAttributeName>
			</Attribute>
			<Attribute> VERSION
				<Index>2</Index>
				<BusinessObjectClass>com.zetec.biz.ZetecVersion</BusinessObjectClass>
			</Attribute>
			<Attribute> DESCRIPTION
				<Index>3</Index>
			</Attribute>
			<Attribute> TYPE
				<Index>4</Index>
			</Attribute>
			<Attribute> MATERIAL
				<Index>5</Index>
			</Attribute>
			<Attribute> DESCRIPTION2
				<Index>6</Index>
			</Attribute>
			<Attribute>
				MAJOR_REV
				<DisplayName>Major Rev</DisplayName>
				<AttributeEditorClass>com.osm.datamgmt.editor.MajorRevAttributeEditor</AttributeEditorClass>
				<Visible>true</Visible>
				<IncludeInLayoutManager>true</IncludeInLayoutManager>
				<Searchable>false</Searchable>
				<InitialRev>-</InitialRev>
				<SecondRev>A</SecondRev>
			</Attribute>
			<Attribute>
				MINOR_REV
				<DisplayName>Minor Rev</DisplayName>
				<AttributeEditorClass>com.osm.datamgmt.editor.MinorRevAttributeEditor</AttributeEditorClass>
				<Visible>true</Visible>
				<IncludeInLayoutManager>true</IncludeInLayoutManager>
				<Searchable>false</Searchable>
				<InitialRev>1</InitialRev>
				<SecondRev>2</SecondRev>
				<NumericOnly>true</NumericOnly>
			</Attribute>
			<Attribute>
				DB_STATE
				<Visible>true</Visible>
				<DisplayName catalog="model" msg_num="455">State</DisplayName>
				<Protect>true</Protect>
				<VisibleInCreateUI>false</VisibleInCreateUI>
				<Values>
					<Value>IN_WORK</Value>
					<Value>IN_CHECK</Value>
					<Value>MFG_CHECK</Value>
					<Value>PROTOTYPE</Value>
					<Value>PILOT</Value>
					<Value>RELEASED</Value>
					<Value>ON_HOLD</Value>
					<Value>OBSOLETE</Value>
				</Values>
			</Attribute>
		</Class>

		<Class extends="DMDrawing, DMReleaseProcess">
			<Name>DRAWING_2D</Name>
			<Attribute>
				NAME
				<Visible>true</Visible>
				<DisplayName>Drawing Number</DisplayName>
				<RollingNumberGeneratorName>New Number Generator</RollingNumberGeneratorName>
				<BusinessObjectClass>com.osm.datamgmt.biz.RollingNumberGenerator</BusinessObjectClass>
				<AttributeEditorClass>com.osm.datamgmt.editor.NumberGeneratorEditor</AttributeEditorClass>
				<CustomAttribute>false</CustomAttribute>
				<IncludeInLayoutManager>true</IncludeInLayoutManager>
				<UseModelName>false</UseModelName>
				<Index>1</Index>
			</Attribute>
			<Attribute> VERSION
				<Index>2</Index>
			</Attribute>
			<Attribute> DESCRIPTION
				<Index>3</Index>
			</Attribute>
			<Attribute> TYPE
				<Index>4</Index>
			</Attribute>
			<Attribute> DESCRIPTION2
				<Index>5</Index>
			</Attribute>
			<Attribute>
				MAJOR_REV
				<DisplayName>Major Rev</DisplayName>
				<AttributeEditorClass>com.osm.datamgmt.editor.MajorRevAttributeEditor</AttributeEditorClass>
				<Visible>true</Visible>
				<IncludeInLayoutManager>true</IncludeInLayoutManager>
				<Searchable>false</Searchable>
				<InitialRev>-</InitialRev>
				<SecondRev>A</SecondRev>
			</Attribute>
			<Attribute>
				MINOR_REV
				<DisplayName>Minor Rev</DisplayName>
				<AttributeEditorClass>com.osm.datamgmt.editor.MinorRevAttributeEditor</AttributeEditorClass>
				<Visible>true</Visible>
				<IncludeInLayoutManager>true</IncludeInLayoutManager>
				<Searchable>false</Searchable>
				<InitialRev>1</InitialRev>
				<SecondRev>2</SecondRev>
				<NumericOnly>true</NumericOnly>
			</Attribute>
			<Attribute>
				DB_STATE
				<Visible>true</Visible>
				<DisplayName catalog="model" msg_num="455">State</DisplayName>
				<Protect>true</Protect>
				<VisibleInCreateUI>false</VisibleInCreateUI>
				<Values>
					<Value>IN_WORK</Value>
					<Value>IN_CHECK</Value>
					<Value>MFG_CHECK</Value>
					<Value>PROTOTYPE</Value>
					<Value>PILOT</Value>
					<Value>RELEASED</Value>
					<Value>ON_HOLD</Value>
					<Value>OBSOLETE</Value>
				</Values>
			</Attribute>
		</Class>

		<Class extends="BASE_CHANGENOTE_2D">
			<Name>CHANGENOTE_2D</Name>
			<Attribute>
				ECN_NUMBER
				<Visible>true</Visible>
				<DisplayName>ECN Number</DisplayName>
				<Index>1</Index>
			</Attribute>
		</Class>

		<Class extends="BASE_CHANGENOTE_3D">
			<Name>CHANGENOTE_3D</Name>
			<Attribute>
				ECN_NUMBER
				<Visible>true</Visible>
				<DisplayName>ECN Number</DisplayName>
				<Index>1</Index>
			</Attribute>
		</Class>

		<Class>
			<Name>DMReleaseProcess</Name>
			<ReleaseProcess>
				<ReleaseLevel>1</ReleaseLevel>
				<CheckDrawing>true</CheckDrawing>
				<AutoReleaseDrawing>true</AutoReleaseDrawing>
				<StateOrders>
					IN_WORK
					<Index>1.0</Index>
					<Type>work</Type>
				</StateOrders>
				<StateOrders>
					IN_CHECK
					<Index>1.2</Index>
					<Type>work</Type>
				</StateOrders>
				<StateOrders>
					MFG_CHECK
					<Index>1.4</Index>
					<Type>work</Type>
				</StateOrders>
				<StateOrders>
					PROTOTYPE
					<Index>2.0</Index>
					<Type>approved</Type>
				</StateOrders>
				<StateOrders>
					PILOT
					<Index>2.1</Index>
					<Type>approved</Type>
				</StateOrders>
				<StateOrders>
					RELEASED
					<Index>3.0</Index>
					<Type>released</Type>
				</StateOrders>
				<StateOrders>
					OBSOLETE
					<Index>4.0</Index>
					<Type>archived</Type>
				</StateOrders>
				<StateAfterRelease>OBSOLETE</StateAfterRelease>
			</ReleaseProcess>
		</Class>

		<Class extends="OSM_ELEMENT">
			<Name>DBR_ELEMENT</Name>
			<Attribute>
				SPEC_701
				<Visible>false</Visible>
				<IsLinkAttribute>true</IsLinkAttribute>
			</Attribute>
		</Class>
	</ClassDefs>

	<DMDefaultWorkspaceTableColumnModel>
		<Column>TYPE</Column>
		<Column>MATERIAL</Column>
		<Column>DESCRIPTION2</Column>
	</DMDefaultWorkspaceTableColumnModel>

	<Options>
		<LoadMasterdataForAllModels>true</LoadMasterdataForAllModels>
		<InitialState>IN_WORK</InitialState>
		<ForceChangeNoteCreation>true</ForceChangeNoteCreation>
		<SearchTaskBarItem>Parts
			<BusinessObjectClass>com.osm.datamgmt.biz.Part</BusinessObjectClass>
		</SearchTaskBarItem>
		<SearchTaskBarItem catalog="model" msg_num="1173">Models
			<BusinessObjectClass>com.osm.datamgmt.biz.Model</BusinessObjectClass>
		</SearchTaskBarItem>
		<SearchTaskBarItem catalog="model" msg_num="1174">Drawings
			<BusinessObjectClass>com.osm.datamgmt.biz.Drawing</BusinessObjectClass>
		</SearchTaskBarItem>
	</Options>
</WMConfig>
Attached Thumbnails
Click image for larger version

Name:	MMRecentListNoDesc01.png
Views:	1030
Size:	44.1 KB
ID:	1880   Click image for larger version

Name:	MMRecentListDescAfterHistory01.png
Views:	1301
Size:	72.5 KB
ID:	1881  

Last edited by gmatelich; 01-03-2013 at 03:33 PM.
Reply With Quote
  #3  
Old 01-08-2013, 10:56 PM
ludw ludw is offline
Registered User
 
Join Date: Dec 2006
Location: France
Posts: 86
Re: My first Java - camel case to upper case

I would think it's a refresh problem.
I already observed some refresh issues on some previous MM versions.
Reply With Quote
  #4  
Old 01-09-2013, 03:27 PM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
Re: My first Java - camel case to upper case

I've tried just clicking the refresh button, but that doesn't do it. Is there a way to initiate the refresh with in the method?
Reply With Quote
  #5  
Old 01-10-2013, 11:43 AM
ludw ludw is offline
Registered User
 
Join Date: Dec 2006
Location: France
Posts: 86
Re: My first Java - camel case to upper case

Could you please try to open a new window and go to the Recent List?
Reply With Quote
  #6  
Old 02-06-2013, 01:25 PM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
Re: My first Java - camel case to upper case

It doesn't seem to be a refresh issue - when I search, when I go to Recent List, when I go to DB Properties, the Description for models is always empty.

If I comment
<BusinessObjectClass>com.zetec.dm.biz.ZetecDMModel3D</BusinessObjectClass>
out of my xml file (thus reverting to standard behavior), Description is showing as expected. But of course, I lose my cool functionality of camel case conversion.

I must be overriding the Description at the wrong point, since it's also messing with the way Description is displayed at other times. Any ideas how to find the more appropriate place to override?
Reply With Quote
  #7  
Old 02-28-2013, 12:08 PM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
Re: My first Java - camel case to upper case

I've been poking at this awhile longer, and it looks like where I really want to go is one of the methods in the com.osm.datamgmt.integration structure - probably under the saveSD method somewhere.

I've run out of time to play with this for awhile, but would be interested to see if anyone else comes up with something.

Thanks
Greg
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 09:43 AM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
You Rated this Thread: