#1
|
||||
|
||||
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() ); } } Last edited by gmatelich; 01-03-2013 at 03:31 PM. |
#2
|
||||
|
||||
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> 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> Last edited by gmatelich; 01-03-2013 at 03:33 PM. |
#3
|
|||
|
|||
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. |
#4
|
||||
|
||||
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?
|
#5
|
|||
|
|||
Re: My first Java - camel case to upper case
Could you please try to open a new window and go to the Recent List?
|
#6
|
||||
|
||||
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? |
#7
|
||||
|
||||
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 |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|