package io.delphiplatform.api.v3.rdb.entity;

import java.util.List;

import io.delphiplatform.api.v3.rdb.service.dto.JpaPropertyPath;

import static io.delphiplatform.api.v3.rdb.entity.CommonJpaPropertyNames.CAMPAIGNS;
import static io.delphiplatform.api.v3.rdb.entity.CommonJpaPropertyNames.CAMPAIGN_PROPERTY;
import static io.delphiplatform.api.v3.rdb.entity.CommonJpaPropertyNames.DATE_PROPERTY;
import static io.delphiplatform.api.v3.rdb.entity.CommonJpaPropertyNames.ID_PROPERTY;
import static io.delphiplatform.api.v3.rdb.entity.CommonJpaPropertyNames.LINK;
import static io.delphiplatform.api.v3.rdb.entity.CommonJpaPropertyNames.NAME;
import static io.delphiplatform.api.v3.rdb.entity.CommonJpaPropertyNames.PROJECTS;

public final class CommonJpaPaths {

    public static final JpaPropertyPath CAMPAIGN_PROJECT_ARTIST_ID = JpaPropertyPath
        .ofJoins(List.of(CAMPAIGN_PROPERTY, PROJECTS, "artists", "artist"))
        .property("artistId");
    public static final JpaPropertyPath CAMPAIGN_PROJECT_ID = JpaPropertyPath
        .ofJoins(List.of(CAMPAIGN_PROPERTY, PROJECTS)).property(ID_PROPERTY);
    public static final JpaPropertyPath CAMPAIGN_ID = JpaPropertyPath.ofJoin(CAMPAIGN_PROPERTY).property(ID_PROPERTY);

    public static final JpaPropertyPath CAMPAIGN_CAT_ID = JpaPropertyPath
        .ofJoins(List.of(CAMPAIGN_PROPERTY, "category")).property(ID_PROPERTY);
    public static final JpaPropertyPath CAMPAIGN_SUB_CAT_ID = JpaPropertyPath
        .ofJoins(List.of(CAMPAIGN_PROPERTY, "subCategory")).property(ID_PROPERTY);
    public static final JpaPropertyPath CAMPAIGN_OBJECTIVE_ID = JpaPropertyPath.ofJoins(CAMPAIGN_PROPERTY, "objective")
        .property(ID_PROPERTY);
    public static final JpaPropertyPath CHARTWEEK = JpaPropertyPath.ofProperty("chartweek");
    public static final JpaPropertyPath DATE = JpaPropertyPath.ofProperty(DATE_PROPERTY);
    public static final JpaPropertyPath MONTH = JpaPropertyPath.ofProperty("month");
    public static final JpaPropertyPath WEEK = JpaPropertyPath.ofProperty("week");
    public static final JpaPropertyPath AD_SET_ID = JpaPropertyPath.ofJoin("adSet").property("adSetId");
    public static final JpaPropertyPath PUBLISHER_PLATFORM = JpaPropertyPath.ofProperty("publisherPlatform");
    public static final JpaPropertyPath GENDER = JpaPropertyPath.ofProperty("gender");
    public static final JpaPropertyPath COUNTRY_CODE = JpaPropertyPath.ofProperty("countryCode");
    public static final JpaPropertyPath AGE = JpaPropertyPath.ofProperty("age");
    public static final JpaPropertyPath ACCOUNT_PROVIDER_NAME = JpaPropertyPath.ofJoin("account")
        .property("providerName");
    public static final JpaPropertyPath ASSET_TYPE_ASSET_TYPE_NAME = JpaPropertyPath.ofJoin("assetType")
        .property("assetTypeName");
    public static final JpaPropertyPath REFERRER_URL_DOMAIN_NAME = JpaPropertyPath.ofJoin("referrer")
        .property("urlDomainName");
    public static final JpaPropertyPath REFERRER_REFERRER_KEY = JpaPropertyPath.ofJoin("referrer")
        .property("referrerKey");
    public static final JpaPropertyPath LINK_ID = JpaPropertyPath.ofJoin(LINK).property("linkId");
    public static final JpaPropertyPath LINK_CAMPAIGN_ID = JpaPropertyPath.ofJoins(LINK, CAMPAIGNS)
        .property(ID_PROPERTY);
    public static final JpaPropertyPath LINK_CAMPAIGN_CAT_ID = JpaPropertyPath.ofJoins(LINK, CAMPAIGNS, "category")
        .property(ID_PROPERTY);
    public static final JpaPropertyPath LINK_CAMPAIGN_SUB_CAT_ID = JpaPropertyPath
        .ofJoins(LINK, CAMPAIGNS, "subCategory").property(ID_PROPERTY);
    public static final JpaPropertyPath LINK_CAMPAIGN_PROJECT_ID = JpaPropertyPath
        .ofJoins(LINK, CAMPAIGNS, PROJECTS).property(ID_PROPERTY);
    public static final JpaPropertyPath LINK_CAMPAIGN_PROJECT_ARTIST_ID = JpaPropertyPath
        .ofJoins(LINK, CAMPAIGNS, PROJECTS, "artists").properties(List.of("projectArtistId", "artist", "artistId"));
    public static final JpaPropertyPath LINK_CAMPAIGN_OBJECTIVE_ID = JpaPropertyPath
        .ofJoins(LINK, CAMPAIGNS, "objective").property(ID_PROPERTY);
    public static final JpaPropertyPath LINK_PROJECT_ID = JpaPropertyPath.ofJoins(List.of(LINK, PROJECTS))
        .property("id");
    public static final JpaPropertyPath LINK_PROJECT_ARTIST_ID = JpaPropertyPath
        .ofJoins(List.of(LINK, PROJECTS, "artists", "artist"))
        .property("artistId");

    // sorting
    public static final JpaPropertyPath LINK_CAMPAIGN_PROJECT_NAME = JpaPropertyPath
        .ofJoins(LINK, CAMPAIGNS, PROJECTS).property(NAME);
    public static final JpaPropertyPath LINK_CAMPAIGN_PROJECT_ARTIST_NAME = JpaPropertyPath
        .ofJoins(LINK, CAMPAIGNS, PROJECTS, "artists", "artist")
        .property("fullName");
    public static final JpaPropertyPath CAMPAIGN_NAME = JpaPropertyPath.ofJoins(List.of(CAMPAIGN_PROPERTY))
        .property(NAME);
    public static final JpaPropertyPath LINK_CAMPAIGN_NAME = JpaPropertyPath.ofJoins(List.of(LINK, CAMPAIGNS))
        .property(NAME);
    public static final JpaPropertyPath CAMPAIGN_PROJECT_NAME = JpaPropertyPath
        .ofJoins(List.of(CAMPAIGN_PROPERTY, PROJECTS)).property(NAME);
    public static final JpaPropertyPath LINK_PROJECT_NAME = JpaPropertyPath.ofJoins(List.of(LINK, PROJECTS))
        .property(NAME);
    public static final JpaPropertyPath CAMPAIGN_PROJECT_ARTIST_NAME = JpaPropertyPath
        .ofJoins(List.of(CAMPAIGN_PROPERTY, PROJECTS, "artists", "artist"))
        .property("fullName");
    public static final JpaPropertyPath LINK_PROJECT_ARTIST_NAME = JpaPropertyPath
        .ofJoins(List.of(LINK, PROJECTS, "artists", "artist"))
        .property("fullName");

    private CommonJpaPaths() {
    }

}
