OrganisationUnit extends
    BaseDimensionalItemObject implements
    MetadataObject,
    CoordinateObject { public String getParentNameGraph( Collection<OrganisationUnit> roots, boolean includeThis ) { StringBuilder builder = new StringBuilder(); List<OrganisationUnit> ancestors = getAncestors( roots ); for ( OrganisationUnit unit : ancestors ) { builder.append( "/" ).append( unit.getName() ); } if ( includeThis ) { builder.append( "/" ).append( name ); } return builder.toString(); } OrganisationUnit();  OrganisationUnit( String name );  OrganisationUnit( String name, String shortName, String code, Date openingDate, Date closedDate,
        String comment );  OrganisationUnit( String name, OrganisationUnit parent, String shortName, String code, Date openingDate,
        Date closedDate, String comment ); @Override void setAutoFields(); void addOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup ); void removeOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup ); void removeAllOrganisationUnitGroups(); void addDataSet( DataSet dataSet ); void removeDataSet( DataSet dataSet ); void removeAllDataSets(); void updateDataSets( Set<DataSet> updates ); void addUser( User user ); void removeUser( User user ); void addCategoryOption( CategoryOption categoryOption ); void removeCategoryOption( CategoryOption categoryOption ); void removeAllUsers(); List<OrganisationUnit> getSortedChildren( SortProperty sortBy ); List<OrganisationUnit> getSortedChildren(); static List<OrganisationUnit> getSortedChildren( Collection<OrganisationUnit> units ); static List<OrganisationUnit> getSortedChildren( Collection<OrganisationUnit> units, SortProperty sortBy ); static List<OrganisationUnit> getSortedGrandChildren( Collection<OrganisationUnit> units ); static List<OrganisationUnit> getSortedGrandChildren( Collection<OrganisationUnit> units,
        SortProperty sortBy ); Set<OrganisationUnit> getGrandChildren(); List<OrganisationUnit> getSortedGrandChildren(); List<OrganisationUnit> getSortedGrandChildren( SortProperty sortBy ); boolean hasChild(); @JsonProperty @JacksonXmlProperty( isAttribute = true ) boolean isLeaf(); @Override boolean hasDescendantsWithCoordinates(); boolean isDescendant( OrganisationUnit ancestor ); boolean isDescendant( Set<OrganisationUnit> ancestors ); boolean hasCoordinatesUp(); OrganisationUnitGroup getGroupInGroupSet( OrganisationUnitGroupSet groupSet ); Long getGroupIdInGroupSet( OrganisationUnitGroupSet groupSet ); String getGroupNameInGroupSet( OrganisationUnitGroupSet groupSet ); String getAncestorNames(); @JsonProperty( "ancestors" ) @JsonSerialize( contentAs = BaseIdentifiableObject.class ) @JacksonXmlElementWrapper( localName = "ancestors", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0 ) List<OrganisationUnit> getAncestors(); List<OrganisationUnit> getAncestors( Collection<OrganisationUnit> roots ); List<String> getAncestorNames( Collection<OrganisationUnit> roots, boolean includeThis ); List<String> getAncestorUids( Set<String> rootUids ); void updateParent( OrganisationUnit newParent ); Set<OrganisationUnit> getChildrenThisIfEmpty(); @JsonProperty( value = "level", access = JsonProperty.Access.READ_ONLY ) @JacksonXmlProperty( localName = "level", isAttribute = true ) int getLevel(); String getParentGraph( Collection<OrganisationUnit> roots ); String getParentNameGraph( Collection<OrganisationUnit> roots, boolean includeThis ); static Map<String, String> getParentGraphMap( List<OrganisationUnit> organisationUnits,
        Collection<OrganisationUnit> roots ); static Map<String, String> getParentNameGraphMap( List<OrganisationUnit> organisationUnits,
        Collection<OrganisationUnit> roots, boolean includeThis ); boolean hasDataElement( DataElement dataElement ); boolean hasCategoryOptions(); boolean isRoot(); @JsonProperty @JsonSerialize( as = BaseIdentifiableObject.class ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) OrganisationUnit getParent(); void setParent( OrganisationUnit parent ); @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) String getPath(); void setPath( String path ); Integer getHierarchyLevel(); void setHierarchyLevel( Integer hierarchyLevel ); @JsonProperty @JsonSerialize( contentAs = BaseIdentifiableObject.class ) @JacksonXmlElementWrapper( localName = "children", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "child", namespace = DxfNamespaces.DXF_2_0 ) Set<OrganisationUnit> getChildren(); void setChildren( Set<OrganisationUnit> children ); @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) Date getOpeningDate(); void setOpeningDate( Date openingDate ); @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) Date getClosedDate(); void setClosedDate( Date closedDate ); @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) String getComment(); void setComment( String comment ); @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) @Property( PropertyType.URL ) String getUrl(); void setUrl( String url ); @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) String getContactPerson(); void setContactPerson( String contactPerson ); @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) String getAddress(); void setAddress( String address ); @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) @Property( PropertyType.EMAIL ) String getEmail(); void setEmail( String email ); @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) @Property( PropertyType.PHONENUMBER ) String getPhoneNumber(); void setPhoneNumber( String phoneNumber ); @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) String getType(); void setType( String type ); @JsonProperty( "organisationUnitGroups" ) @JsonSerialize( contentAs = BaseIdentifiableObject.class ) @JacksonXmlElementWrapper( localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0 ) Set<OrganisationUnitGroup> getGroups(); void setGroups( Set<OrganisationUnitGroup> groups ); @JsonProperty @JsonSerialize( contentAs = BaseIdentifiableObject.class ) @JacksonXmlElementWrapper( localName = "dataSets", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "dataSet", namespace = DxfNamespaces.DXF_2_0 ) Set<DataSet> getDataSets(); void setDataSets( Set<DataSet> dataSets ); @JsonProperty @JsonSerialize( contentAs = BaseIdentifiableObject.class ) @JacksonXmlElementWrapper( localName = "programs", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "program", namespace = DxfNamespaces.DXF_2_0 ) Set<Program> getPrograms(); void setPrograms( Set<Program> programs ); @JsonProperty @JsonSerialize( contentAs = BaseIdentifiableObject.class ) @JacksonXmlElementWrapper( localName = "users", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "userItem", namespace = DxfNamespaces.DXF_2_0 ) Set<User> getUsers(); void setUsers( Set<User> users ); Set<CategoryOption> getCategoryOptions(); void setCategoryOptions( Set<CategoryOption> categoryOptions ); @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) Geometry getGeometry(); void setGeometry( Geometry geometry ); @Override FeatureType getFeatureType(); @Override String getCoordinates(); @Override boolean hasCoordinates(); @Override DimensionItemType getDimensionItemType(); List<String> getGroupNames(); void setGroupNames( List<String> groupNames ); Double getValue(); void setValue( Double value ); boolean isCurrentParent(); void setCurrentParent( boolean currentParent ); @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) Integer getMemberCount(); void setMemberCount( Integer memberCount ); @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) String getGeometryAsJson(); void setGeometryAsJson( String geometryAsJsonString ); void removeProgram( Program program ); static final String KEY_USER_ORGUNIT; static final String KEY_USER_ORGUNIT_CHILDREN; static final String KEY_USER_ORGUNIT_GRANDCHILDREN; static final String KEY_LEVEL; static final String KEY_ORGUNIT_GROUP; }
@Test public void testGetParentNameGraph() { unitD.setParent( unitC ); unitC.setParent( unitB ); unitB.setParent( unitA ); List<OrganisationUnit> roots = new ArrayList<>( Arrays.asList( unitB ) ); String expected = "/OrgUnitB/OrgUnitC"; assertEquals( expected, unitD.getParentNameGraph( roots, false ) ); expected = "/OrgUnitA/OrgUnitB/OrgUnitC"; assertEquals( expected, unitD.getParentNameGraph( null, false ) ); }