55 lines
2.8 KiB
Python
55 lines
2.8 KiB
Python
import os
|
|
from modules.logger_tool import initialise_logger
|
|
import modules.database.tools.neo4j_driver_tools as driver_tools
|
|
import modules.database.tools.neo4j_session_tools as session_tools
|
|
import modules.database.tools.neontology_tools as neon
|
|
import modules.database.schemas.entities as neo_entity
|
|
import modules.database.schemas.nodes.schools.curriculum as curriculum_schemas
|
|
import modules.database.schemas.relationships.curriculum_relationships as curriculum_relationships
|
|
import modules.database.schemas.relationships.entity_relationships as ent_rels
|
|
import modules.database.schemas.relationships.entity_curriculum_rels as ent_cur_rels
|
|
import pandas as pd
|
|
|
|
class SchoolSyllabusProvider:
|
|
def __init__(self):
|
|
self.driver = driver_tools.get_driver()
|
|
self.logger = initialise_logger(__name__, os.getenv("LOG_LEVEL"), os.getenv("LOG_PATH"), 'default', True)
|
|
|
|
def process_syllabus_data(self, school_node, database_name, dataframes):
|
|
"""Process syllabus data from Excel file and create nodes in the database"""
|
|
try:
|
|
# This method will contain the syllabus-specific processing code from the
|
|
# original SchoolCurriculumProvider, starting from where the comment
|
|
# "# Curriculum specific database initialisation begins here" was placed
|
|
|
|
# We'll implement this in the next iteration after confirming the basic
|
|
# structure changes work correctly
|
|
|
|
return {
|
|
"status": "success",
|
|
"message": "Syllabus data processed successfully"
|
|
}
|
|
|
|
except Exception as e:
|
|
self.logger.error(f"Error processing syllabus data: {str(e)}")
|
|
return {"status": "error", "message": str(e)}
|
|
|
|
def check_syllabus_status(self, school_node, database_name):
|
|
"""Check if syllabus data exists in the database"""
|
|
try:
|
|
with self.driver.session(database=database_name) as session:
|
|
result = session.run("""
|
|
MATCH (s:School {unique_id: $school_id})
|
|
OPTIONAL MATCH (s)-[:HAS_CURRICULUM_STRUCTURE]->(:CurriculumStructure)-[:INCLUDES_KEY_STAGE]->(:KeyStage)-[:INCLUDES_KEY_STAGE_SYLLABUS]->(ks:KeyStageSyllabus)
|
|
OPTIONAL MATCH (s)-[:HAS_CURRICULUM_STRUCTURE]->(:CurriculumStructure)-[:INCLUDES_KEY_STAGE]->(:KeyStage)-[:INCLUDES_YEAR_GROUP_SYLLABUS]->(ys:YearGroupSyllabus)
|
|
RETURN count(ks) > 0 OR count(ys) > 0 as has_syllabus
|
|
""", school_id=school_node.unique_id)
|
|
|
|
has_syllabus = result.single()["has_syllabus"]
|
|
|
|
return {"has_syllabus": has_syllabus}
|
|
|
|
except Exception as e:
|
|
self.logger.error(f"Error checking syllabus status: {str(e)}")
|
|
raise
|