CoCreate User Forum  

Go Back   CoCreate User Forum > Applications > Data Management

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 02-12-2007, 12:03 AM
ng-first ng-first is offline
Registered User
 
Join Date: Feb 2007
Posts: 45
mandatory attribute

Hi all !!!
I have another question for you .

I'm working whit "Change Class" window; is there a way to make mandatory an attribute in this window?

I mean, I would like that, when I click 'OK' in this windows and the save proces starts, if there is some attribute with null value or empty string value the save process stops end returns an error message.

I hope I'm not confused !!!

Thank's in advanced,
Nadia
Reply With Quote
  #2  
Old 02-12-2007, 04:16 AM
jdh jdh is offline
Registered User
 
Join Date: Jan 2007
Location: Fort Collins
Posts: 17
Re: mandatory attribute

There are a couple of ways to make required attributes. The easiest way is to create a data dictionary for the attribute that requires a value. This requires no coding and has the added bennifit in that in release 14.20 or later, required attributes are marked with a star (*).

If the required values or more complicated than can be expressed by data dictionaries, you could write a PreApplyListener. PreApplyListeners are called just before an element is applied to the database and allow you to verify values. If something is wrong, you just throw and exception and the text of the exception is shown as an error message to the user.
Reply With Quote
  #3  
Old 02-15-2007, 01:15 AM
ng-first ng-first is offline
Registered User
 
Join Date: Feb 2007
Posts: 45
Re: mandatory attribute

thank a lot for your suggestion :-) !!
I used PreApplyListeners xml tag, and now I can control if the attribute of masterdata in null.
But now I have another question for you; how can descover if an object (a Part) is a part of a Group?
I saw that there is a coloum in data base table that tells us if a Part is a PartAssembly but if no, how can get if the part is in such grups?

thank in advanced :-) ,
Nadia
Reply With Quote
  #4  
Old 02-15-2007, 04:51 AM
jdh jdh is offline
Registered User
 
Join Date: Jan 2007
Location: Fort Collins
Posts: 17
Re: mandatory attribute

Do you mean "is this part an assembly?". If so you could ask the part for its children and test to see if any of the children are parts. However, asking for children may cause queries to the database which can greatly affect performance.

For example:

private boolean isPartAnAssembly(Part part) throws WMException {
boolean b = false;
List<WMElement> children = part.getChildren(); //may query!
for(WMElement child : children) {
if (child instanceof Part) {
b = true;
break;
}
}
return b;
}
Reply With Quote
  #5  
Old 02-15-2007, 09:58 AM
John van Doorn's Avatar
John van Doorn John van Doorn is offline
Registered User
 
Join Date: Nov 2002
Location: The Netherlands
Posts: 83
Re: mandatory attribute

Hi,

If you would like to know if an Masterdata belongs to an assembly, you can use an existing method m.isAssembly() where m is an instance of a DMMasterdata object.


Kind Regards,
John
__________________
High performance CAD workstations
Please visit us at https://www.cadware.nl
Reply With Quote
  #6  
Old 02-16-2007, 05:41 AM
ng-first ng-first is offline
Registered User
 
Join Date: Feb 2007
Posts: 45
Re: mandatory attribute

Thank's for your answers.
now I can discover if a part of a Group belongs to an assembly, but i have to do some controls only in the 'DB Property' window.
I kwon that the attribute editor associate to an attribute, is being called each time the attribute be must load: so in the 'DB Property' window, in 'Change Class' window, and so on ...
How I can do this?

Than's for your help,
Nadia
Reply With Quote
Reply


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

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 04:33 PM.



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.