Map<AttributeTypeDescription, Integer> attributeNameToSelectedValuesCountMap = new HashMap<AttributeTypeDescription, Integer>();
Set<ObjectClassDescription> selectedObjectClasses = new HashSet<ObjectClassDescription>();
for ( IValue value : values )
{
String type = value.getAttribute().getType();
AttributeTypeDescription atd = value.getAttribute().getAttributeTypeDescription();
AttributeHierarchy ah = value.getAttribute().getEntry().getAttributeWithSubtypes( type );
// check if (part of) RDN is selected
if ( value.isRdnPart() )
{
message.append( NLS.bind( Messages.getString( "DeleteAction.DeletePartOfRDN" ), value.toString() ) ); //$NON-NLS-1$
message.append( BrowserCoreConstants.LINE_SEPARATOR );
message.append( BrowserCoreConstants.LINE_SEPARATOR );
}
// check if a required objectClass is selected
if ( value.getAttribute().isObjectClassAttribute() )
{
selectedObjectClasses.add( value.getAttribute().getEntry().getBrowserConnection().getSchema()
.getObjectClassDescription( value.getStringValue() ) );
}
// check if ALL values of objectClass or a MUST attribute are selected
if ( !attributeNameToSelectedValuesCountMap.containsKey( atd ) )
{
attributeNameToSelectedValuesCountMap.put( atd, new Integer( 0 ) );
}
int count = ( attributeNameToSelectedValuesCountMap.get( atd ) ).intValue() + 1;
attributeNameToSelectedValuesCountMap.put( atd, new Integer( count ) );
if ( value.getAttribute().isObjectClassAttribute() && count >= ah.getValueSize() )
{
message.append( Messages.getString( "DeleteAction.DeleteObjectClass" ) ); //$NON-NLS-1$
message.append( BrowserCoreConstants.LINE_SEPARATOR );
message.append( BrowserCoreConstants.LINE_SEPARATOR );
continue;
}
else if ( value.getAttribute().isMustAttribute() && count >= ah.getValueSize() )
{
message.append( NLS.bind( Messages.getString( "DeleteAction.DeleteMust" ), type ) ); //$NON-NLS-1$
message.append( BrowserCoreConstants.LINE_SEPARATOR );
message.append( BrowserCoreConstants.LINE_SEPARATOR );
}
// check if a value of an operational attribute is selected
if ( !SchemaUtils.isModifiable( atd ) )
{
message.append( NLS.bind( Messages.getString( "DeleteAction.DeleteNonModifiable" ), type ) ); //$NON-NLS-1$
message.append( BrowserCoreConstants.LINE_SEPARATOR );
message.append( BrowserCoreConstants.LINE_SEPARATOR );
continue;
}
}
// check if a required objectClass is selected
if ( values.size() > 0 && !selectedObjectClasses.isEmpty() )
{
IEntry entry = values.iterator().next().getAttribute().getEntry();
Schema schema = entry.getBrowserConnection().getSchema();
// get remaining attributes
Collection<ObjectClassDescription> remainingObjectClasses = entry.getObjectClassDescriptions();
remainingObjectClasses.removeAll( selectedObjectClasses );
Set<AttributeTypeDescription> remainingAttributeSet = new HashSet<AttributeTypeDescription>();
for ( ObjectClassDescription ocd : remainingObjectClasses )
{
{
Collection<String> mustAttrs = SchemaUtils.getMustAttributeTypeDescriptionNamesTransitive( ocd,
schema );
for ( String mustAttr : mustAttrs )
{
AttributeTypeDescription atd = entry.getBrowserConnection().getSchema()
.getAttributeTypeDescription( mustAttr );
remainingAttributeSet.add( atd );
}
Collection<String> mayAttrs = SchemaUtils.getMayAttributeTypeDescriptionNamesTransitive( ocd,
schema );
for ( String mayAttr : mayAttrs )
{
AttributeTypeDescription atd = entry.getBrowserConnection().getSchema()
.getAttributeTypeDescription( mayAttr );
remainingAttributeSet.add( atd );
}
}
}