Skip to content

Commit

Permalink
Add childOrder to ContentVersion #9559
Browse files Browse the repository at this point in the history
  • Loading branch information
vbradnitski committed Jul 8, 2022
1 parent 0f3befd commit df17fb2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Objects;

import com.enonic.xp.annotation.PublicApi;
import com.enonic.xp.index.ChildOrder;
import com.enonic.xp.security.PrincipalKey;

@PublicApi
Expand All @@ -20,6 +21,8 @@ public final class ContentVersion

private final Instant timestamp;

private final ChildOrder childOrder;

private final String comment;

private final ContentVersionPublishInfo publishInfo;
Expand All @@ -33,6 +36,7 @@ private ContentVersion( Builder builder )
this.modified = builder.modified;
this.comment = builder.comment;
this.timestamp = builder.timestamp;
this.childOrder = builder.childOrder;
this.id = builder.id;
this.publishInfo = builder.publishInfo;
this.workflowInfo = builder.workflowInfo;
Expand Down Expand Up @@ -63,6 +67,11 @@ public Instant getTimestamp()
return timestamp;
}

public ChildOrder getChildOrder()
{
return childOrder;
}

public ContentVersionId getId()
{
return id;
Expand Down Expand Up @@ -114,14 +123,15 @@ public boolean equals( final Object o )
final ContentVersion that = (ContentVersion) o;
return Objects.equals( id, that.id ) && Objects.equals( modifier, that.modifier ) &&
Objects.equals( displayName, that.displayName ) && Objects.equals( modified, that.modified ) &&
Objects.equals( timestamp, that.timestamp ) && Objects.equals( comment, that.comment ) &&
Objects.equals( publishInfo, that.publishInfo ) && Objects.equals( workflowInfo, that.workflowInfo );
Objects.equals( timestamp, that.timestamp ) && Objects.equals( childOrder, that.childOrder ) &&
Objects.equals( comment, that.comment ) && Objects.equals( publishInfo, that.publishInfo ) &&
Objects.equals( workflowInfo, that.workflowInfo );
}

@Override
public int hashCode()
{
return Objects.hash( id, modifier, displayName, modified, timestamp, comment, publishInfo, workflowInfo );
return Objects.hash( id, modifier, displayName, modified, timestamp, childOrder, comment, publishInfo, workflowInfo );
}

public static final class Builder
Expand All @@ -134,6 +144,8 @@ public static final class Builder

private Instant timestamp;

private ChildOrder childOrder;

private String comment;

private ContentVersionId id;
Expand Down Expand Up @@ -176,6 +188,12 @@ public Builder timestamp( Instant timestamp )
return this;
}

public Builder childOrder( ChildOrder childOrder )
{
this.childOrder = childOrder;
return this;
}

public Builder comment( String comment )
{
this.comment = comment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import nl.jqno.equalsverifier.EqualsVerifier;

import com.enonic.xp.index.ChildOrder;
import com.enonic.xp.security.PrincipalKey;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -44,6 +45,7 @@ public void testBuilder()
.id( ContentVersionId.from( "a" ) )
.modified( now1 )
.timestamp( now2 )
.childOrder( ChildOrder.manualOrder() )
.modifier( PrincipalKey.ofAnonymous() )
.displayName( "contentVersion" )
.comment( "comment" )
Expand All @@ -59,6 +61,7 @@ public void testBuilder()
assertEquals( "contentVersion", version.getDisplayName() );
assertEquals( publishInfo, version.getPublishInfo() );
assertEquals( workflowInfo, version.getWorkflowInfo() );
assertEquals( ChildOrder.manualOrder(), version.getChildOrder() );
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ private ContentVersion doCreateContentVersion( final NodeVersionMetadata nodeVer
.comment( "No comments" )
.modified( data.getProperty( ContentPropertyNames.MODIFIED_TIME ).getInstant() )
.timestamp( nodeVersionMetadata.getTimestamp() )
.childOrder( nodeVersion.getChildOrder() )
.modifier( PrincipalKey.from( data.getProperty( ContentPropertyNames.MODIFIER ).getString() ) )
.id( ContentVersionId.from( nodeVersionMetadata.getNodeVersionId().toString() ) )
.publishInfo( doCreateContentVersionPublishInfo( nodeVersionMetadata.getNodeCommitId(), data.getRoot() ) )
Expand Down

0 comments on commit df17fb2

Please sign in to comment.