@Override public List<ParsingError> doValidate() { // Component checks List<ParsingError> result = new ArrayList<> (); if( Utils.isEmptyOrWhitespaces( this.componentName )) result.add( error( ErrorCode.CMD_MISSING_COMPONENT_NAME )); else if( this.component == null ) result.add( error( ErrorCode.CMD_INEXISTING_COMPONENT, component( this.componentName ))); else if( ! this.component.getAncestors().isEmpty()) { Instance resolvedParentInstance; if( this.parentInstancePath == null ) result.add( error( ErrorCode.CMD_MISSING_PARENT_INSTANCE )); else if(( resolvedParentInstance = this.context.resolveInstance( this.parentInstancePath )) == null ) result.add( error( ErrorCode.CMD_NO_MATCHING_INSTANCE, instance( this.parentInstancePath ))); else if( ! this.component.getAncestors().contains( resolvedParentInstance.getComponent())) result.add( error( ErrorCode.CMD_NOT_AN_ACCEPTABLE_PARENT, component( this.componentName ))); } else if( this.parentInstancePath != null ) { result.add( error( ErrorCode.CMD_CANNOT_HAVE_ANY_PARENT, component( this.componentName ))); } // Instance stuff if( Utils.isEmptyOrWhitespaces( this.instanceName )) result.add( error( ErrorCode.CMD_MISSING_INSTANCE_NAME )); else if( ! this.instanceName.matches( ParsingConstants.PATTERN_FLEX_ID )) result.add( error( ErrorCode.CMD_INVALID_INSTANCE_NAME, instance( this.instanceName ))); String newInstancePath = (this.parentInstancePath == null ? "" : this.parentInstancePath) + "/" + this.instanceName; if( this.context.instancePathToComponentName.containsKey( newInstancePath )) result.add( error( ErrorCode.CMD_CONFLICTING_INSTANCE_NAME )); return result; }
list.addAll( children ? c.getChildren() : c.getAncestors()); for( Facet facet : findAllFacets( c )) list.addAll( children ? facet.getChildren() : facet.getAncestors());
@Test public void testInsertChild() { Component component_1 = new Component( "comp 1" ); Component component_1_1 = new Component( "comp 11" ); Assert.assertEquals( 0, component_1.getAncestors().size()); Assert.assertEquals( 0, component_1.getChildren().size()); Assert.assertEquals( 0, component_1_1.getAncestors().size()); Assert.assertEquals( 0, component_1_1.getChildren().size()); component_1.addChild( component_1_1 ); Assert.assertEquals( 0, component_1.getAncestors().size()); Assert.assertEquals( 1, component_1.getChildren().size()); Assert.assertEquals( 1, component_1_1.getAncestors().size()); Assert.assertEquals( 0, component_1_1.getChildren().size()); Assert.assertEquals( component_1_1, component_1.getChildren().iterator().next()); Assert.assertEquals( component_1, component_1_1.getAncestors().iterator().next()); Assert.assertNotSame( component_1, component_1_1 ); }
for( AbstractType type : comp.getAncestors()) { if( type instanceof Facet ) { ancestors.add( type );
for( AbstractType type : comp.getAncestors()) { if( type instanceof Facet ) { ancestors.add( type );