package com.capgemini.framework.teamcenter.object.pom.workspace.bom;

import com.capgemini.framework.teamcenter.authent.TcSession;
import com.capgemini.framework.teamcenter.exceptions.KurtException;
import com.capgemini.framework.teamcenter.object.pom.workspace.bom.generic.*;
import com.capgemini.framework.teamcenter.object.pom.workspace.bom.part.*;
import com.capgemini.framework.teamcenter.object.pom.workspace.bom.product.TcProduct;
import com.capgemini.framework.teamcenter.object.pom.workspace.bom.product.TcProductRevision;
import com.capgemini.framework.teamcenter.object.types.SnecmaObjectTypes;
import com.teamcenter.soa.client.model.strong.Item;
import com.teamcenter.soa.client.model.strong.ItemRevision;
import com.teamcenter.soa.client.model.strong.WorkspaceObject;

public class TcBomObjectFactory {
    private final WorkspaceObject modelObject;
    private final TcSession session;

    public TcBomObjectFactory(final TcSession session, final WorkspaceObject modelObject) {
        this.session = session;
        this.modelObject = modelObject;
    }


    public TcBomObject create() throws KurtException {
        TcBomObject tcBomObject;
        switch (modelObject.getTypeObject().getName()) {
            case SnecmaObjectTypes.PRODUCT:
                tcBomObject = new TcProduct(session, (Item) modelObject);
                break;
            case SnecmaObjectTypes.GENERIC:
                tcBomObject = new TcGeneric((Item) modelObject);
                break;
            case SnecmaObjectTypes.RF_GENERIC:
                tcBomObject = new TcRFGeneric((Item) modelObject);
                break;
            case SnecmaObjectTypes.GENERIC_ASSEMB:
                tcBomObject = new TcGenericAssemb((Item) modelObject);
                break;
            case SnecmaObjectTypes.GENERIC_REVISION:
                tcBomObject = new TcGenericRevision((ItemRevision) modelObject);
                break;
            case SnecmaObjectTypes.GENERIC_ASSEMB_REVISION:
                tcBomObject = new TcGenericAssembRevision((ItemRevision) modelObject);
                break;
            /*case SnecmaObjectTypes.SUPERMODEL_REVISION:
                tcBomObject = new TcSuper
            */
            case SnecmaObjectTypes.RF_GENERIC_REVISION:
                tcBomObject = new TcRFGenericRevision((ItemRevision) modelObject);
                break;
            case SnecmaObjectTypes.PART_AERO_REVISION:
                tcBomObject = new TcPartAeroRevision((ItemRevision) modelObject);
                break;
            case SnecmaObjectTypes.PART_NO_AERO_REVISION:
                tcBomObject = new TcPartNoAeroRevision((ItemRevision) modelObject);
                break;
            case SnecmaObjectTypes.PART_MAT_REVISION:
                tcBomObject = new TcPartMatRevision((ItemRevision) modelObject);
                break;
            case SnecmaObjectTypes.STANDARD_REVISION:
                tcBomObject = new TcStandardRevision((ItemRevision) modelObject);
                break;
            case SnecmaObjectTypes.DET_REVISION:
                tcBomObject = new TcDetRevision((ItemRevision) modelObject);
                break;
            case SnecmaObjectTypes.ALTERNATE_REVISION:
                tcBomObject = new TcAlternateRevision((ItemRevision) modelObject);
                break;
            case SnecmaObjectTypes.PART_ASSEMB_REVISION:
                tcBomObject = new TcPartAssembRevision((ItemRevision) modelObject);
                break;
            case SnecmaObjectTypes.RF_PART_REVISION:
                tcBomObject = new TcRFPartRevision((ItemRevision) modelObject);
              break;
          case SnecmaObjectTypes.ALTERNATE:
            tcBomObject = new TcAlternate((Item) modelObject);
                break;
            case SnecmaObjectTypes.DET:
                tcBomObject = new TcDet((Item) modelObject);
                break;
            case SnecmaObjectTypes.PART_AERO:
                tcBomObject = new TcPartAero((Item) modelObject);
                break;
            case SnecmaObjectTypes.PART_ASSEMB:
                tcBomObject = new TcPartAssemb((Item) modelObject);
                break;
            case SnecmaObjectTypes.PART_MAT:
                tcBomObject = new TcPartMat((Item) modelObject);
                break;
            case SnecmaObjectTypes.PART_NO_AERO:
                tcBomObject = new TcPartNoAero((Item) modelObject);
                break;
            case SnecmaObjectTypes.STANDARD:
                tcBomObject = new TcStandard((Item) modelObject);
                break;
            case SnecmaObjectTypes.PRODUCT_REVISION:
                tcBomObject = new TcProductRevision(session, (ItemRevision) modelObject);
                break;
            default:
                throw new KurtException("Invalid Teamcenter type for: (" + modelObject.getTypeObject().getName() + ")" + modelObject.getUid());
        }

        return tcBomObject;
    }
}
