package com.atlassian.bitbucket.internal.mirroring.mirror.dao.v0;

import net.java.ao.Accessor;
import net.java.ao.OneToMany;
import net.java.ao.RawEntity;
import net.java.ao.schema.*;

import static com.atlassian.bitbucket.internal.mirroring.mirror.dao.v0.AoConstantsV0.*;

/**
 * Represents the mapping of a project in the mirror to the project in the upstream server
 *
 * @since 4.6
 */
@Table(AoProjectMappingV0.TABLE)
public interface AoProjectMappingV0 extends RawEntity<Integer> {
    String TABLE = "PROJECT_MAPPING";

    /**
     * @return the project ID in this server
     */
    @NotNull
    @PrimaryKey(LOCAL_ID_COLUMN)
    Integer getLocalId();

    /**
     * @return the project ID in the upstream server
     */
    @Accessor(EXTERNAL_ID_COLUMN)
    @NotNull
    @StringLength(DEFAULT_STRING_COLUMN_LENGTH)
    @Unique
    String getExternalId();

    /**
     * @return the ID of the upstream server
     */
    @Accessor(UPSTREAM_ID_COLUMN)
    @Indexed
    @NotNull
    @StringLength(DEFAULT_STRING_COLUMN_LENGTH)
    String getUpstreamId();

    @OneToMany(reverse = "getLocalProjectId")
    AoRepositoryMappingV0[] getRepositoryMappings();

    @Accessor(IN_PROGRESS_COLUMN)
    @NotNull
    Boolean getInProgress();
}
