public override BaseResource[] SynchronizeIds(BaseResource[] source, Uri subjectUri, BaseResource[] target)
        {
            CorrectingAnswer correctingAnswer = source.OfType <CorrectingAnswer>().SingleOrDefault();

            correctingAnswer.Id = subjectUri;
            correctingAnswer.CorrectingAnswerHasQuestion
            .SingleOrDefault()
            .QuestionHasAnsweringBodyAllocation
            .SingleOrDefault()
            .AnsweringBodyAllocationHasAnsweringBody
            .AnsweringBodyHasWrittenAnswer
            .SingleOrDefault()
            .Id = subjectUri;
            IndexingAndSearchThing iast = source.OfType <IndexingAndSearchThing>().SingleOrDefault();

            iast.Id = subjectUri;

            return(new BaseResource[] { correctingAnswer, iast });
        }
        public override BaseResource[] TransformSource(XDocument doc)
        {
            var questionElements = doc?.Element("response")?.Element("result")?.Element("doc")?.Elements("arr")?.ToList();

            if (questionElements == null)
            {
                return(null);
            }
            Response data = new Response();

            data.QuestionUri = FindXElementByAttributeName(questionElements, "correctedItem_uri", "str").GetText();
            if (data.QuestionUri == null)
            {
                data.QuestionUri = FindXElementByAttributeName(questionElements, "correctedItem_t", "str").GetText();
            }
            questionUriText = data.QuestionUri;
            data.CorrectingAnsweringDeptSesId   = FindXElementByAttributeName(questionElements, "answeringDept_ses", "int").GetText();
            data.CorrectingAnsweringMemberSesId = FindXElementByAttributeName(questionElements, "correctingMember_ses", "int").GetText();
            data.CorrectingAnswerText           = FindXElementByAttributeName(questionElements, "content_t", "str").GetText();

            var dateElements = doc.Element("response").Element("result").Element("doc").Elements("date").ToList();

            data.CorrectingDateOfAnswer = dateElements.Where(x => x.Attribute("name").Value == "date_dt").FirstOrDefault().GetDate();

            CorrectingAnswer correctingAnswer = new CorrectingAnswer();

            correctingAnswer.Id              = GenerateNewId();
            correctingAnswer.AnswerText      = new string[] { data.CorrectingAnswerText };
            correctingAnswer.AnswerGivenDate = data.CorrectingDateOfAnswer;
            if (string.IsNullOrWhiteSpace(data.CorrectingAnsweringMemberSesId))
            {
                logger.Warning("No information about correcting minister");
            }
            else
            {
                Uri ministerId = GetMemberId(data.CorrectingAnsweringMemberSesId, data.CorrectingDateOfAnswer, logger);

                if (ministerId != null)
                {
                    correctingAnswer.AnswerHasAnsweringPerson = new Person[]
                    {
                        new Person()
                        {
                            Id = ministerId
                        }
                    }
                }
                ;
                else
                {
                    logger.Warning($"Minister with Ses Id ({data.CorrectingAnsweringMemberSesId}) not found");
                }
            }
            Uri questionId = IdRetrieval.GetSubject("indexingAndSearchUri", data.QuestionUri, false, logger);

            Question question = null;

            if (questionId != null)
            {
                question = new Question()
                {
                    Id = questionId
                };
                correctingAnswer.CorrectingAnswerHasQuestion = new Question[] { question };
            }
            else
            {
                logger.Warning($"Question with Uri ({data.QuestionUri}) not found");
                return(null);
            }

            Answer originalAnswer = giveMeOriginalAnswer(questionId);

            if (originalAnswer != null)
            {
                correctingAnswer.AnswerReplacesAnswer = originalAnswer;
            }
            else
            {
                logger.Warning($"No answer found to replace for question with Uri ({data.QuestionUri})");
                return(null);
            }

            AnsweringBodyAllocation correctingAnsweringBodyAllocation = giveMeCorrectingAnsweringBodyAllocation(data, questionId);

            if (correctingAnsweringBodyAllocation != null)
            {
                question.QuestionHasAnsweringBodyAllocation = new AnsweringBodyAllocation[] { correctingAnsweringBodyAllocation };
                correctingAnsweringBodyAllocation.AnsweringBodyAllocationHasAnsweringBody.AnsweringBodyHasWrittenAnswer
                    = new WrittenAnswer[] { new WrittenAnswer()
                                            {
                                                Id = correctingAnswer.Id
                                            } };
            }
            else
            {
                return(null);
            }

            IndexingAndSearchThing iast = new IndexingAndSearchThing();
            var uriElements             = doc.Element("response").Element("result").Element("doc").Elements("str").ToList();

            iast.IndexingAndSearchUri = new String[] { uriElements.Where(x => x.Attribute("name").Value == "uri").FirstOrDefault().GetText() };

            return(new BaseResource[] { correctingAnswer, iast });
        }