package com.capgemini.framework.teamcenter.object.types;

import com.capgemini.framework.teamcenter.TeamcenterObjectTypes;
import com.google.common.base.Joiner;

import java.util.regex.Pattern;

/**
 * Class regrouping all the used type of Teamcenter Revision objects.
 */
public final class SnecmaObjectTypes extends TeamcenterObjectTypes {

    /**
     * The Teamcenter type for an Effectivity.
     */
    public static final String EFFECTIVITY = "Effectivity";
    /**
     * The Teamcenter type for a Product.
     */
    public static final String PRODUCT = "Product";
    /**
     * The Teamcenter type for a Product Revision.
     */
    public static final String PRODUCT_REVISION = PRODUCT + REVISION;
    /**
     * The Teamcenter type for a Product Revision Master.
     */
    public static final String PRODUCT_REVISION_MASTER = PRODUCT + REVISION + MASTER;
    /**
     * The Teamcenter type for a Generic.
     */
    public static final String GENERIC = "Generic";
    /**
     * The Teamcenter type for a Generic Revision.
     */
    public static final String GENERIC_REVISION = GENERIC + REVISION;
    /**
     * The Teamcenter type for a SuperModel Revision.
     */
    public static final String SUPERMODEL = "Super Model";
    /**
     * The Teamcenter type for a SuperModel Revision.
     */
    public static final String SUPERMODEL_REVISION = SUPERMODEL + REVISION;
    /**
     * The Teamcenter type for a Generic Assemb.
     */
    public static final String GENERIC_ASSEMB = "Generic Assemb";
    /**
     * The Teamcenter type for a Generic Assemb Revision.
     */
    public static final String GENERIC_ASSEMB_REVISION = GENERIC_ASSEMB + REVISION;
    /**
     * The Teamcenter type for a Generic PV Revision Master (for both Generic and Generic Assemb).
     */
    public static final String GENERIC_PV_REVISION_MASTER = "Generic PV Revision Master";
    /**
     * The Teamcenter type for a RF Generic.
     */
    public static final String RF_GENERIC = "RF Generic";
    /**
     * The Teamcenter type for a RF Generic Revision.
     */
    public static final String RF_GENERIC_REVISION = RF_GENERIC + REVISION;
    /**
     * The Teamcenter type for a RF Part.
     */
    public static final String RF_PART = "RF Part";
    /**
     * The Teamcenter type for a RF Part Revision.
     */
    public static final String RF_PART_REVISION = RF_PART + REVISION;
    /**
     * The Teamcenter type for a RF Part Assemb.
     */
    public static final String RF_PART_ASSEMB = "RF Part Assemb";
    /**
     * The Teamcenter type for a RF Part Assemb Revision.
     */
    public static final String RF_PART_ASSEMB_REVISION = RF_PART_ASSEMB + REVISION;
    /**
     * The Teamcenter type for a RF Admin 1 Revision Master.
     */
    public static final String RF_ADMIN_1_REVISION_MASTER = "RF Admin 1 Revision Master";
    /**
     * The Teamcenter type for a RF Admin.
     */
    public static final String RF_ADMIN = "RF Admin";
    /**
     * The Teamcenter type for a RF Master.
     */
    public static final String RF_MASTER = "RF Master";
    /**
     * The Teamcenter type for a RF Admin Revision.
     */
    public static final String RF_ADMIN_REVISION = RF_ADMIN + REVISION;
    /**
     * The Teamcenter type for a RF Admin Revision Master.
     */
    public static final String RF_ADMIN_REVISION_MASTER = RF_ADMIN_REVISION + MASTER;

    /**
     * The Teamcenter type for a RF Admin A Revision.
     */
    public static final String RF_ADMIN_A_REVISION = "RF Admin A Revision";

    /**
     * The Teamcenter type for a RF Admin AP Revision.
     */
    public static final String RF_ADMIN_AP_REVISION = "RF Admin AP Revision";
    /**
     * The Teamcenter type for a RF Admin AG Revision.
     */
    public static final String RF_ADMIN_AG_REVISION = "RF Admin AG Revision";
    /**
     * The Teamcenter type for a Descriptif.
     */
    public static final String DESCRIPTIF = "Descriptif";
    /**
     * The Teamcenter type for a Descriptif Revision.
     */
    public static final String DESCRIPTIF_REVISION = DESCRIPTIF + REVISION;
    /**
     * The Teamcenter type for a Alternate.
     */
    public static final String ALTERNATE = "Alternate";
    /**
     * The Teamcenter type for a Alternate Revision.
     */
    public static final String ALTERNATE_REVISION = ALTERNATE + REVISION;
    /**
     * The Teamcenter type for a DET.
     */
    public static final String DET = "DET";
    /**
     * The Teamcenter type for a DET Revision.
     */
    public static final String DET_REVISION = DET + REVISION;
    /**
     * The Teamcenter type for a Part Aero.
     */
    public static final String PART_AERO = "Part Aero";
    /**
     * The Teamcenter type for a Part Aero Revision.
     */
    public static final String PART_AERO_REVISION = PART_AERO + REVISION;
    /**
     * The Teamcenter type for a Part No Aero.
     */
    public static final String PART_NO_AERO = "Part No Aero";
    /**
     * The Teamcenter type for a Part No Aero Revision.
     */
    public static final String PART_NO_AERO_REVISION = PART_NO_AERO + REVISION;
    /**
     * The Teamcenter type for a Part Assemb.
     */
    public static final String PART_ASSEMB = "Part Assemb";
    /**
     * The Teamcenter type for a Part Assemb Revision.
     */
    public static final String PART_ASSEMB_REVISION = PART_ASSEMB + REVISION;
    /**
     * The Teamcenter type for a Part Assemb Revision Master.
     */
    public static final String PART_ASSEMB_REVISION_MASTER = PART_ASSEMB_REVISION + MASTER;
    /**
     * The Teamcenter type for a Part Mat.
     */
    public static final String PART_MAT = "Part Mat";
    /**
     * The Teamcenter type for a Part Mat Revision.
     */
    public static final String PART_MAT_REVISION = PART_MAT + REVISION;
    /**
     * The Teamcenter type for a Part Mat Revision Master.
     */
    public static final String PART_MAT_REVISION_MASTER = PART_MAT_REVISION + MASTER;
    /**
     * The Teamcenter type for a Standard.
     */
    public static final String STANDARD = "Standard";
    /**
     * The Teamcenter type for a Standard Revision.
     */
    public static final String STANDARD_REVISION = STANDARD + REVISION;
    /**
     * The Teamcenter type for a Standard Revision.
     */
    public static final String STANDARD_REVISION_MASTER = STANDARD_REVISION + MASTER;
    /**
     * The Teamcenter type for a UnitRevision.
     */
    public static final String UNIT_REVISION = "Unit Revision";
    /**
     * The Teamcenter type for the Master Form of a UnitRevision.
     */
    public static final String UNIT_REVISION_MASTER = UNIT_REVISION + MASTER;
    /**
     * The Teamcenter type for a geomertry.
     */
    public static final String GEOMETRY = "Geometry";
    /**
     * The Teamcenter type for a geomertry REVISION.
     */
    public static final String GEOMETRY_REVISION = GEOMETRY + REVISION;
    /**
     * The Teamcenter type for a geomertry Revision Master.
     */
    public static final String GEOMETRY_REVISION_MASTER = GEOMETRY_REVISION + MASTER;
    /**
     * The Teamcenter type for a changeRequest of type MACE.
     */
    public static final String PV4_MACE_REVISION = "PV4_MACERevision";
    /**
     * The Teamcenter type for a changeRequest of type DCAD.
     */
    public static final String PV4_DCAD_REVISION = "PV4_DCADRevision";
    /**
     * The Teamcenter type for a changeRequest of type CAD SCR (with effectivity).
     */
    public static final String PV4_CAD_SCR_REVISION = "PV4_CAD_SCRRevision";
    /**
     * The Teamcenter type for a changeRequest of type CAD ACR (without effectivity).
     */
    public static final String PV4_CAD_ACR_REVISION = "PV4_CAD_ACRRevision";
    /**
     * The Teamcenter type for a (Deprecated) changeRequest of type CR Deprec.
     */
    public static final String PV4_CR_DEPREC = "PV4_CR_DEPREC";
    /**
     * The Teamcenter type for a CN Deprecié Revision.
     */
    public static final String CN_DEPRECIE_REVISION = "CN Déprécié Revision";
    /**
     * The Teamcenter type for a CR Deprecié Revision.
     */
    public static final String CR_DEPRECIE_REVISION = "CR Déprécié Revision";
    /**
     * The Teamcenter type for a PV4_CN_DEPRECRevision.
     */
    public static final String PV4_CN_DEPREC_REVISION = "PV4_CN_DEPRECRevision"; // No space!
    /**
     * The Teamcenter type for a PV4_CR_DEPRECRevision.
     */
    public static final String PV4_CR_DEPREC_REVISION = "PV4_CR_DEPRECRevision"; // No space!
    /**
     * The Teamcenter type for a Revision EngChange.
     */
    public static final String REVISION_ENG_CHANGE = "Revision EngChange";
    /**
     * The Teamcenter type for a FPP Revision.
     */
    public static final String FPP_REVISION = "PV4_FPPRevision";
    /**
     * The Teamcenter Father type of all Documents.
     */
    public static final String DOC_PV_REVISION = "Doc PV Revision";
    /**
     * The Teamcenter type for a DocTechnic.
     */
    public static final String DOC_TECHNIC = "DocTechnic";
    /**
     * The Teamcenter type for a DocTechnic Revision.
     */
    public static final String DOC_TECHNIC_REVISION = "DocTechnic Revision";
    /**
     * The Teamcenter type for a DocTechnic Revision Master.
     */
    public static final String DOC_TECHNIC_REVISION_MASTER = DOC_TECHNIC_REVISION + MASTER;
    /**
     * The Teamcenter type for a Geometry.
     */
    public static final String DOC_GEOMETRY = "Geometry";
    /**
     * The Teamcenter type for a Geometry Revision.
     */
    public static final String DOC_GEOMETRY_REVISION = "Geometry Revision";
    /**
     * The Teamcenter type for a DocDrawing.
     */
    public static final String DOC_DRAWING = "DocDrawing";
    /**
     * The Teamcenter type for a DocDrawing Revision.
     */
    public static final String DOC_DRAWING_REVISION = "DocDrawing Revision";
    /**
     * The Teamcenter type for a DocDrawing Revision Master.
     */
    public static final String DOC_DRAWING_REVISION_MASTER = "DocDrawing Revision Master";
    /**
     * The Teamcenter type for a doc PV Revision Master.
     */
    public static final String DOC_PV_REVISION_MASTER = "Doc PV Revision Master";
    /**
     * The Teamcenter type for a DocNorm.
     */
    public static final String DOC_NORM = "DocNorm";
    /**
     * The Teamcenter type for a DocNorm Revision.
     */
    public static final String DOC_NORM_REVISION = DOC_NORM + REVISION;
    /**
     * The Teamcenter type for a DocNorm Master.
     */
    public static final String DOC_NORM_MASTER = DOC_NORM + MASTER;
    /**
     * The Teamcenter type for a DocNorm Master.
     */
    public static final String DOC_NORM_REVISION_MASTER = DOC_NORM_REVISION + MASTER;
    /**
     * The Teamcenter type for a DocDrawing Revision Master.
     */
    public static final String DOC_NORM_STANDARD = "DocNormStandard";
    /**
     * The Teamcenter type for a DocDrawing Revision Master.
     */
    public static final String DOC_NORM_STANDARD_REVISION = DOC_NORM_STANDARD + REVISION;
    /**
     * The Teamcenter type for an Approbation SO.
     */
    public static final String APPROBATION_SO = "Approbation SO";
    /**
     * The Teamcenter type IMAN Relation: REACH Documents.
     */
    public static final String FOLDER_PV_REACH_DOCS = "_PV_reach_docs";
    /**
     * The Teamcenter type IMAN Relation: ITAR Documents.
     */
    public static final String FOLDER_PV_ITAR_DOCS = "_PV_itar_docs";
    /**
     * The Teamcenter type IMAN Relation: Definition Documents.
     */
    public static final String FOLDER_PV_DEFINITION_DOCS = "_PV_definition_docs";
    /**
     * The Teamcenter type IMAN Relation: Reference Documents.
     */
    public static final String FOLDER_REFERENCED_DOCS = "_PV_reference_docs";
    public static final Pattern PART_REVISION_PATTERN = Pattern.compile("^((" + Joiner.on(")|(").join(PART_AERO_REVISION, PART_ASSEMB_REVISION,
            PART_NO_AERO_REVISION, ALTERNATE_REVISION, DET_REVISION, PART_MAT_REVISION, STANDARD_REVISION) + "))$");
    public static final Pattern ALT_OR_DET_PATTERN = Pattern.compile("^((" + ALTERNATE_REVISION + ")|(" + DET_REVISION + "))$");
    public static final Pattern PART_PATTERN = Pattern.compile("^((" + Joiner.on(")|(").join(PART_AERO, PART_ASSEMB,
            PART_NO_AERO, ALTERNATE, DET, PART_MAT, STANDARD) + "))$");
    public static final Pattern GENERIC_PATTERN = Pattern.compile("^((" + Joiner.on(")|(").join(GENERIC_REVISION,
            GENERIC_ASSEMB_REVISION) + "))$");
    public static final Pattern SUPERMODEL_PATTERN = Pattern.compile("^((" + Joiner.on(")|(").join(SUPERMODEL,
            SUPERMODEL_REVISION) + "))$");
    public static final Pattern PRODUCT_REV_PATTERN = Pattern.compile("^((" + PRODUCT_REVISION + "))$");
    public static final Pattern RF_REV_PATTERN = Pattern.compile("^((" + Joiner.on(")|(").join(RF_PART_ASSEMB_REVISION,
            RF_PART_REVISION) + "))$");

    private SnecmaObjectTypes() {
        super();
        // Move along, nothing to see
    }

    public static boolean isAltOrDet(final String objectType) {
        return isAlt(objectType) || isDet(objectType);
    }

    public static boolean isDet(final String objectType) {
        return DET_REVISION.equals(objectType);
    }

    public static boolean isAlt(final String objectType) {
        return ALTERNATE_REVISION.equals(objectType);
    }

    /**
     * Returns <code>true</code> if the provided object type String matches a Part Revision.<br>
     * Any of the following will be a match:
     * <ul>
     * <li>Part Aero Revision</li>
     * <li>Part No Aero Revision</li>
     * <li>Part Assemb Revision</li>
     * <li>Part Mat Revision</li>
     * <li>Alternate Revision</li>
     * <li>Standard Revision</li>
     * <li>DET Revision</li>
     * </ul>
     *
     * @param objectType the String describing the object type to be tested
     * @return <code>true</code> if the object type matches a Part, <code>false</code> otherwise
     */
    public static boolean isPartRevision(final String objectType) {
        return PART_REVISION_PATTERN.matcher(objectType).matches();
    }

    /**
     * Returns <code>true</code> if the provided object type String matches a Part.<br>
     * Any of the following will be a match:
     * <ul>
     * <li>Part Aero</li>
     * <li>Part No Aero</li>
     * <li>Part Assemb</li>
     * <li>Part Mat</li>
     * <li>Alternate</li>
     * <li>Standard</li>
     * <li>DET</li>
     * </ul>
     *
     * @param objectType the String describing the object type to be tested
     * @return <code>true</code> if the object type matches a Part, <code>false</code> otherwise
     */
    public static boolean isPart(final String objectType) {
        return PART_PATTERN.matcher(objectType).matches();
    }

    /**
     * Returns <code>true</code> if the provided object type String matches a Generic.<br>
     * Any of the following will be a match:
     * <ul>
     * <li>Generic Revision</li>
     * <li>Generic Assemb Revision</li>
     * </ul>
     *
     * @param objectType the String describing the object type to be tested
     * @return <code>true</code> if the object type matches a Generic, <code>false</code> otherwise
     */
    public static boolean isGenericRevision(final String objectType) {
        return GENERIC_PATTERN.matcher(objectType).matches();
    }

    /**
     * Returns <code>true</code> if the provided object type String matches a SuperModel.<br>
     * Any of the following will be a match:
     * <ul>
     * <li>SuperModel Revision</li>
     * </ul>
     *
     * @param objectType the String describing the object type to be tested
     * @return <code>true</code> if the object type matches a Generic, <code>false</code> otherwise
     */
    public static boolean isSuperModelRevision(final String objectType) {
        return SUPERMODEL_PATTERN.matcher(objectType).matches();
    }

    /**
     * Returns <code>true</code> if the provided object type String matches a Product.<br>
     * Any of the following will be a match:
     * <ul>
     * <li>Product Revision</li>
     * </ul>
     *
     * @param objectType the String describing the object type to be tested
     * @return <code>true</code> if the object type matches a Product Revision, <code>false</code> otherwise
     */
    public static boolean isProductRevision(final String objectType) {
        return PRODUCT_REV_PATTERN.matcher(objectType).matches();
    }

    /**
     * Returns <code>true</code> if the provided object type String matches a Product.<br>
     * Any of the following will be a match:
     * <ul>
     * <li>Product Revision</li>
     * </ul>
     *
     * @param objectType the String describing the object type to be tested
     * @return <code>true</code> if the object type matches a Product Revision, <code>false</code> otherwise
     */
    public static boolean isRFRevision(final String objectType) {
        return RF_REV_PATTERN.matcher(objectType).matches();
    }
}
