Beispiel #1
0
def getContractorDetails():
    lengthList = len(d)
    ## Update the details to the database temp
    connObj = dbu.getConn()
    #contractor_type = (type(d[lengthList -1]["contractors"]))
    for i in range(0, len(d[lengthList - 1]["contractors"])):
        # Get the project level details from the json file
        contractor_name = d[lengthList - 1]["contractors"][i]["name"]
        contractor_email = d[lengthList - 1]["contractors"][i]["email"]
        contractor_phone = d[lengthList - 1]["contractors"][i]["phone"]
        contractor_pcontact = d[lengthList -
                                1]["contractors"][i]["primary_contact"]

        # --------------------------------------------------------
        # First truncate the data from project and location table
        # --------------------------------------------------------
        LsqlQuery = "TRUNCATE TABLE TEMP.CONTRACTORS"
        dbu.executeQueryString(LsqlQuery, connObj)

        # --------------------------------------------------------
        # Insert data to project and location table
        # --------------------------------------------------------
        execSQL = "INSERT INTO TEMP.CONTRACTORS(NAME,EMAIL,PHONE,PM_CONTACT) VALUES (%s,%s,%s,%s);"
        execData = (contractor_name, contractor_email, contractor_phone,
                    contractor_pcontact)
        dbu.executeSQLData(execSQL, execData, connObj)

    connObj.close()
Beispiel #2
0
def writeBundleList_DictActivity(bundle_item):
    connObj = dbu.getConn()
    print('I am entering fn writeBundleList_DictActivity(i) ---')
    bundles_name = d[len(d) - 1]["bundles"][bundle_item]["name"]
    bundles_phases = d[len(d) - 1]["bundles"][bundle_item]["phases"]

    activities_name = getwriteBundleList_DictActivity("bundles", "activities",
                                                      "name", bundle_item)
    activities_contractor = getwriteBundleList_DictActivity(
        "bundles", "activities", "contractor", bundle_item)
    activities_total_planned_hours = getwriteBundleList_DictActivity(
        "bundles", "activities", "total_planned_hours", bundle_item)
    activities_total_planned_units = getwriteBundleList_DictActivity(
        "bundles", "activities", "total_planned_units", bundle_item)
    activities_planned_start = getwriteBundleList_DictActivity(
        "bundles", "activities", "planned_start", bundle_item)
    activities_planned_end = getwriteBundleList_DictActivity(
        "bundles", "activities", "planned_end", bundle_item)
    activities_actual_start = getwriteBundleList_DictActivity(
        "bundles", "activities", "actual_start", bundle_item)
    activities_actual_end = getwriteBundleList_DictActivity(
        "bundles", "activities", "actual_end", bundle_item)
    activities_unit_name = d[
        len(d) - 1]["bundles"][bundle_item]["activities"]["unit"]["name"]
    activities_material = getwriteBundleList_DictActivity(
        "bundles", "activities", "material", bundle_item)

    # --------------------------------------------------------
    # Insert data to project and location table
    # --------------------------------------------------------
    planned_start = datetime.datetime.strptime(
        activities_planned_start, '%m%d%Y').date().strftime('%Y%m%d')
    planned_end = datetime.datetime.strptime(
        activities_planned_end, '%m%d%Y').date().strftime('%Y%m%d')
    actual_start = datetime.datetime.strptime(
        activities_actual_start, '%m%d%Y').date().strftime('%Y%m%d')
    actual_end = datetime.datetime.strptime(activities_actual_end,
                                            '%m%d%Y').date().strftime('%Y%m%d')
    prj_name = getProjectName()

    execSQL = "INSERT INTO TEMP.ACTIVITIES(NAME,CONTRACTOR_NAME,TOTAL_PLANNED_HOURS,PROJECT_NAME,TOTAL_PLANNED_UNITS,PLANNED_START,PLANNED_END,UNIT_NAME,ACTUAL_START,ACTUAL_END) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);"
    execData = (activities_name, activities_contractor,
                activities_total_planned_hours, prj_name,
                activities_total_planned_units, planned_start, planned_end,
                activities_unit_name, actual_start, actual_end)
    dbu.executeSQLData(execSQL, execData, connObj)

    print('###############-- writeBundleList_DictActivity() --######')
    print('writing values')
    print('Bundle Name : %s' % bundles_name)
    print('Bundle Phases : %s' % bundles_phases)
    print('Activity Name : %s' % activities_name)
    print('Activity Unit Name : %s' % activities_unit_name)
    print('Activity Material: %s' % activities_material)
    print('#####################')

    connObj.close()
Beispiel #3
0
def getProjectDetails():
    # Get the project level details from the json file
    project_name = getItemsChildLevel("project", "name")
    project_start_date = getItemsChildLevel("project", "start")
    project_end_date = getItemsChildLevel("project", "end")
    project_workdays = getItemsChildLevel("project", "workdays")
    project_budget = getItemsChildLevel("project", "budget")
    project_loc_street1 = getItemsSubChildLevel("project", "location",
                                                "street1")
    project_loc_street2 = getItemsSubChildLevel("project", "location",
                                                "street2")
    project_loc_city = getItemsSubChildLevel("project", "location", "city")
    project_loc_state = getItemsSubChildLevel("project", "location", "state")
    project_loc_postal = getItemsSubChildLevel("project", "location", "postal")
    project_loc_country = getItemsSubChildLevel("project", "location",
                                                "country")

    print(project_workdays)

    ## Update the details to the database temp
    connObj = dbu.getConn()
    # --------------------------------------------------------
    # First truncate the data from project and location table
    # --------------------------------------------------------
    LsqlQuery = "TRUNCATE TABLE TEMP.PROJECTS"
    dbu.executeQueryString(LsqlQuery, connObj)

    # --------------------------------------------------------
    # Insert data to project and location table
    # --------------------------------------------------------
    start_date = datetime.datetime.strptime(project_start_date,
                                            '%m%d%Y').date().strftime('%Y%m%d')
    end_date = datetime.datetime.strptime(project_end_date,
                                          '%m%d%Y').date().strftime('%Y%m%d')

    execSQL = "INSERT INTO TEMP.PROJECTS(NAME, WORKDAYS,BUDGET,LOCATION_NAME,START) VALUES (%s,%s,%s,%s,%s);"
    execData = (project_name, json.dumps(project_workdays),
                int(project_budget), project_loc_state, start_date)
    dbu.executeSQLData(execSQL, execData, connObj)
    connObj.close()
Beispiel #4
0
def writeBundle_Activity():
    ## Update the details to the database temp
    connObj = dbu.getConn()

    bundles_name = getItemsChildLevel(len(d), "bundles", "name")
    bundles_phases = getItemsChildLevel(len(d), "bundles", "phases")
    activities_name = getItemsSubChildLevel("bundles", "activities", "name")
    activities_contractor = getItemsSubChildLevel("bundles", "activities",
                                                  "contractor")
    activities_total_planned_hours = getItemsSubChildLevel(
        "bundles", "activities", "total_planned_hours")
    activities_total_planned_units = getItemsSubChildLevel(
        "bundles", "activities", "total_planned_units")
    activities_planned_start = getItemsSubChildLevel("bundles", "activities",
                                                     "planned_start")
    activities_planned_end = getItemsSubChildLevel("bundles", "activities",
                                                   "planned_end")
    activities_actual_start = getItemsSubChildLevel("bundles", "activities",
                                                    "actual_start")
    activities_actual_end = getItemsSubChildLevel("bundles", "activities",
                                                  "actual_end")
    activities_unit_name = d[len(d) -
                             1]["bundles"]["activities"]["unit"]["name"]
    activities_material = getItemsSubChildLevel("bundles", "activities",
                                                "material")

    # --------------------------------------------------------
    # First truncate the data from project and location table
    # --------------------------------------------------------
    #LsqlQuery = "TRUNCATE TABLE TEMP.PROJECTS"
    #dbu.executeQueryString(LsqlQuery, connObj)

    # --------------------------------------------------------
    # Insert data to project and location table
    # --------------------------------------------------------
    planned_start = datetime.datetime.strptime(
        activities_planned_start, '%m%d%Y').date().strftime('%Y%m%d')
    planned_end = datetime.datetime.strptime(
        activities_planned_end, '%m%d%Y').date().strftime('%Y%m%d')
    actual_start = datetime.datetime.strptime(
        activities_actual_start, '%m%d%Y').date().strftime('%Y%m%d')
    actual_end = datetime.datetime.strptime(activities_actual_end,
                                            '%m%d%Y').date().strftime('%Y%m%d')
    prj_name = getProjectName()

    execSQL = "INSERT INTO TEMP.ACTIVITIES(NAME,CONTRACTOR_NAME,TOTAL_PLANNED_HOURS,PROJECT_NAME,TOTAL_PLANNED_UNITS,PLANNED_START,PLANNED_END,UNIT_NAME,ACTUAL_START,ACTUAL_END) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);"
    execData = (activities_name, activities_contractor,
                activities_total_planned_hours, prj_name,
                activities_total_planned_units, planned_start, planned_end,
                activities_unit_name, actual_start, actual_end)
    print(execSQL)
    print(execData)
    dbu.executeSQLData(execSQL, execData, connObj)
    connObj.close()

    print('#####################')
    print('writing values')
    print('Bundle Name : %s' % bundles_name)
    print('Bundle Phases : %s' % bundles_phases)
    print('Activity Name : %s' % activities_name)
    print('Activity Unit Name : %s' % activities_unit_name)
    print('Activity Material: %s' % activities_material)
    print('#####################')
Beispiel #5
0
def writeActivitiesData_MultiBundles_MultipleActivities(bundle_item):
    activityList = []
    node1 = "bundles"
    node2 = "activities"
    ## Update the details to the database temp
    connObj = dbu.getConn()

    #write the values of bundles
    bundles_name = d[len(d) - 1][node1][bundle_item]["name"]
    bundles_phases = d[len(d) - 1][node1][bundle_item]["phases"]
    #L_item_activities = d[lengthList - 1]["bundles"][bundle_item]["activities"]
    for i in range(0, len(item_activities)):
        activities_name = getItems_MultiBundle_MultiActivity(
            node1, node2, "name", bundle_item, i)
        activities_contractor = getItems_MultiBundle_MultiActivity(
            node1, node2, "contractor", bundle_item, i)
        activities_total_planned_hours = getItems_MultiBundle_MultiActivity(
            node1, node2, "total_planned_hours", bundle_item, i)
        activities_total_planned_units = getItems_MultiBundle_MultiActivity(
            node1, node2, "total_planned_units", bundle_item, i)
        activities_planned_start = getItems_MultiBundle_MultiActivity(
            node1, node2, "planned_start", bundle_item, i)
        activities_planned_end = getItems_MultiBundle_MultiActivity(
            node1, node2, "planned_end", bundle_item, i)
        activities_actual_start = getItems_MultiBundle_MultiActivity(
            node1, node2, "actual_start", bundle_item, i)
        activities_actual_end = getItems_MultiBundle_MultiActivity(
            node1, node2, "actual_end", bundle_item, i)
        activities_unit_name = d[
            len(d) -
            1]["bundles"][bundle_item]["activities"][i]["unit"]["name"]
        activities_material = getItems_MultiBundle_MultiActivity(
            node1, node2, "material", bundle_item, i)

        print(activities_planned_start)

        # --------------------------------------------------------
        # First truncate the data from project and location table
        # --------------------------------------------------------
        # LsqlQuery = "TRUNCATE TABLE TEMP.PROJECTS"
        # dbu.executeQueryString(LsqlQuery, connObj)

        # --------------------------------------------------------
        # Insert data to project and location table
        # --------------------------------------------------------
        planned_start = datetime.datetime.strptime(
            activities_planned_start, '%m%d%Y').date().strftime('%Y%m%d')
        planned_end = datetime.datetime.strptime(
            activities_planned_end, '%m%d%Y').date().strftime('%Y%m%d')
        actual_start = datetime.datetime.strptime(
            activities_actual_start, '%m%d%Y').date().strftime('%Y%m%d')
        actual_end = datetime.datetime.strptime(
            activities_actual_end, '%m%d%Y').date().strftime('%Y%m%d')
        prj_name = getProjectName()

        execSQL = "INSERT INTO TEMP.ACTIVITIES(NAME,CONTRACTOR_NAME,TOTAL_PLANNED_HOURS,PROJECT_NAME,TOTAL_PLANNED_UNITS,PLANNED_START,PLANNED_END,UNIT_NAME,ACTUAL_START,ACTUAL_END) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);"
        execData = (activities_name, activities_contractor,
                    activities_total_planned_hours, prj_name,
                    activities_total_planned_units, planned_start, planned_end,
                    activities_unit_name, actual_start, actual_end)
        dbu.executeSQLData(execSQL, execData, connObj)

        print('#####################-- MultiBundle-MultiActivity----')
        print(execSQL)
        print(execData)
        print('writing values')
        print('Bundle Name : %s' % bundles_name)
        print('Bundle Phases : %s' % bundles_phases)
        print('Activity Name : %s' % activities_name)
        print('Activity Unit Name : %s' % activities_unit_name)
        print('Activity Material: %s' % activities_material)
        print('#####################')

    connObj.close()
Beispiel #6
0
def writeActivitiesData_MultipleActivities():
    activityList = []
    connObj = dbu.getConn()

    node1 = "bundles"
    node2 = "activities"
    bundles_name = getItemsChildLevel(len(d), "bundles", "name")
    bundles_phases = getItemsChildLevel(len(d), "bundles", "phases")

    for i in range(0, len(item_activities)):
        activities_name = getItemsSubChildLevel_List(len(d), node1, node2,
                                                     "name", i)
        activities_contractor = getItemsSubChildLevel_List(
            len(d), node1, node2, "contractor", i)
        activities_total_planned_hours = getItemsSubChildLevel_List(
            len(d), node1, node2, "total_planned_hours", i)
        activities_total_planned_units = getItemsSubChildLevel_List(
            len(d), node1, node2, "total_planned_units", i)
        activities_planned_start = getItemsSubChildLevel_List(
            len(d), node1, node2, "planned_start", i)
        activities_planned_end = getItemsSubChildLevel_List(
            len(d), node1, node2, "planned_end", i)
        activities_actual_start = getItemsSubChildLevel_List(
            len(d), node1, node2, "actual_start", i)
        activities_actual_end = getItemsSubChildLevel_List(
            len(d), node1, node2, "actual_end", i)
        activities_unit_name = d[len(d) -
                                 1]["bundles"]["activities"][i]["unit"]["name"]
        activities_material = getItemsSubChildLevel_List(
            len(d), "bundles", "activities", "material", i)

        # --------------------------------------------------------
        # Insert data to project and location table
        # --------------------------------------------------------
        planned_start = datetime.datetime.strptime(
            activities_planned_start, '%m%d%Y').date().strftime('%Y%m%d')
        planned_end = datetime.datetime.strptime(
            activities_planned_end, '%m%d%Y').date().strftime('%Y%m%d')
        actual_start = datetime.datetime.strptime(
            activities_actual_start, '%m%d%Y').date().strftime('%Y%m%d')
        actual_end = datetime.datetime.strptime(
            activities_actual_end, '%m%d%Y').date().strftime('%Y%m%d')
        prj_name = getProjectName()

        execSQL = "INSERT INTO TEMP.ACTIVITIES(NAME,CONTRACTOR_NAME,TOTAL_PLANNED_HOURS,PROJECT_NAME,TOTAL_PLANNED_UNITS,PLANNED_START,PLANNED_END,UNIT_NAME,ACTUAL_START,ACTUAL_END) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);"
        execData = (activities_name, activities_contractor,
                    activities_total_planned_hours, prj_name,
                    activities_total_planned_units, planned_start, planned_end,
                    activities_unit_name, actual_start, actual_end)

        dbu.executeSQLData(execSQL, execData, connObj)

        print('#####################')
        print(execSQL)
        print(execData)
        print('writing values')
        print('Bundle Name : %s' % bundles_name)
        print('Bundle Phases : %s' % bundles_phases)
        print('Activity Name : %s' % activities_name)
        print('Activity Unit Name : %s' % activities_unit_name)
        print('Activity Material: %s' % activities_material)
        print('#####################')