public CategorisationObjectBaseCore(ICategorisationObject categorisation0,
				ISdmxObjectRetrievalManager retMan) : base(categorisation0) {
			IMaintainableObject maint = retMan.GetMaintainable(categorisation0
					.StructureReference);
			IMaintainableObject cs = retMan.GetMaintainable(categorisation0
					.CategoryReference);
			/* foreach */
			foreach (IIdentifiableObject ident  in  cs.IdentifiableComposites) {
				if (categorisation0.CategoryReference.IsMatch(ident)) {
					category = (ICategoryObject) ident;
					break;
				}
			}
			if (categorisation0.StructureReference.TargetReference.IsMaintainable && categorisation0.StructureReference.IsMatch(maint)) {
				structure = maint;
			} else {
				foreach (IIdentifiableObject ident1  in  maint.IdentifiableComposites) {
					if (categorisation0.StructureReference.IsMatch(ident1)) {
						structure = ident1;
						break;
					}
				}
			}
			if (structure == null) {
				throw new ReferenceException(categorisation0.StructureReference);
			}
			if (category == null) {
				throw new ReferenceException(categorisation0.CategoryReference);
			}
		}
        /// <summary>
        /// The update references.
        /// </summary>
        /// <param name="maintianable">
        /// The maintianable.
        /// </param>
        /// <param name="updateReferences">
        /// The update references.
        /// </param>
        /// <param name="newVersionNumber">
        /// The new version number.
        /// </param>
        /// <returns>
        /// The <see cref="ICategorisationObject"/>.
        /// </returns>
        public ICategorisationObject UpdateReferences(ICategorisationObject maintianable, IDictionary<IStructureReference, IStructureReference> updateReferences, string newVersionNumber)
        {
            ICategorisationMutableObject categorisationMutable = maintianable.MutableInstance;

            IStructureReference target = updateReferences[categorisationMutable.CategoryReference];
            if (target != null)
            {
                categorisationMutable.CategoryReference = target;
            }
            target = updateReferences[categorisationMutable.StructureReference];
            if (target != null)
            {
                categorisationMutable.StructureReference = target;
            }
            return categorisationMutable.ImmutableInstance;
        }
        private void SetGeneralTab(ICategorisationObject cat)
        {
            txt_id.Text = cat.Id;
            txtAgenciesReadOnly.Text = cat.AgencyId;
            txt_version.Text = cat.Version;
            chk_isFinal.Checked = cat.IsFinal.IsTrue;

            FileDownload31.ucID = cat.Id;
            FileDownload31.ucAgency = cat.AgencyId;
            FileDownload31.ucVersion = cat.Version;
            FileDownload31.ucArtefactType = "Categorization";

            txt_uri.Text = (cat.Uri != null) ? cat.Uri.AbsoluteUri : string.Empty;
            txt_urn.Text = (cat.Urn != null) ? cat.Urn.AbsoluteUri : string.Empty;
            txt_valid_from.Text = (cat.StartDate != null) ? string.Format("{0}/{1}/{2}", cat.StartDate.Date.Value.Day.ToString(), cat.StartDate.Date.Value.Month.ToString(), cat.StartDate.Date.Value.Year.ToString()) : string.Empty;
            txt_valid_to.Text = (cat.EndDate != null) ? string.Format("{0}/{1}/{2}", cat.EndDate.Date.Value.Day.ToString(), cat.EndDate.Date.Value.Month.ToString(), cat.EndDate.Date.Value.Year.ToString()) : string.Empty;

            txt_name_locale.Text = _localizedUtils.GetNameableName(cat);
            txt_description_locale.Text = _localizedUtils.GetNameableDescription(cat);

            // Svuoto le griglie
            //===========================================
            if (AddTextName.TextObjectList != null && AddTextName.TextObjectList.Count != 0)
            {
                AddTextName.ClearTextObjectList();
            }
            if (AddTextDescription.TextObjectList != null && AddTextDescription.TextObjectList.Count != 0)
            {
                AddTextDescription.ClearTextObjectList();
            }
            if (AnnotationGeneralControl.AnnotationObjectList != null && AnnotationGeneralControl.AnnotationObjectList.Count != 0)
            {
                AnnotationGeneralControl.ClearAnnotationsSession();
            }

            txt_id.Enabled = false;
            txt_version.Enabled = false;
            cmb_agencies.Enabled = false;

            if (Request["ACTION"] == "VIEW" || cat.IsFinal.IsTrue || Utils.ViewMode)
            {
                AddTextName.Visible = false;
                txt_all_names.Visible = true;
                txt_all_names.Text = _localizedUtils.GetNameableName(cat);

                AddTextDescription.Visible = false;
                txt_all_description.Visible = true;
                txt_all_description.Text = _localizedUtils.GetNameableDescription(cat);
            }
            else
            {
                AspConfirmationExit = "true";

                AddTextName.Visible = true;
                AddTextDescription.Visible = true;
                txt_all_description.Visible = false;
                txt_all_names.Visible = false;

                AddTextName.InitTextObjectList = cat.Names;
                AddTextDescription.InitTextObjectList = cat.Descriptions;
            }

            if (_action != Action.VIEW)
            {
                DuplicateArtefact1.Visible = false;
            }

            AnnotationGeneralControl.AddText_ucOpenTabName = AnnotationGeneralControl.ClientID;
            AnnotationGeneralControl.AnnotationObjectList = cat.MutableInstance.Annotations;
            AnnotationGeneralControl.EditMode = !cat.IsFinal.IsTrue;
            AnnotationGeneralControl.OwnerAgency = txtAgenciesReadOnly.Text;

            if (cat.IsFinal.IsTrue)
            {
                txt_valid_from.Enabled = false;
                txt_valid_to.Enabled = false;
                txt_name_locale.Enabled = false;
                txt_description_locale.Enabled = false;
                txt_uri.Enabled = false;
                chk_isFinal.Enabled = false;

            }
            else
            {
                txt_valid_from.Enabled = true;
                txt_valid_to.Enabled = true;
                txt_name_locale.Enabled = true;
                txt_description_locale.Enabled = true;
                txt_uri.Enabled = true;
                chk_isFinal.Enabled = true;
            }

            if (_action == Action.INSERT)
            {
                cmb_agencies.Visible = true;
                txtAgenciesReadOnly.Visible = false;
            }
            else
            {
                cmb_agencies.Visible = false;
                txtAgenciesReadOnly.Visible = true;
            }

            SetStructureDetailPanel();

            string categoryId = cat.CategoryReference.IdentifiableIds.First();
            WSModel wsModel = new WSModel();
            ISdmxObjects sdmxInput = wsModel.GetCategoryScheme(new ArtefactIdentity(cat.CategoryReference.MaintainableId, cat.CategoryReference.AgencyId, cat.CategoryReference.Version), false, false);

            ddlCategorySchemeList.Text = string.Format("{0}-{1}-{2}", cat.CategoryReference.MaintainableId, cat.CategoryReference.AgencyId, cat.CategoryReference.Version);

            ICategorySchemeObject currentCategoryScheme = sdmxInput.CategorySchemes.First();

            txtSelectedCategory.Text = cat.CategoryReference.IdentifiableIds[0].ToString();

            SdmxStructureEnumType type = cat.StructureReference.MaintainableStructureEnumType;

            switch (type)
            {
                case SdmxStructureEnumType.CodeList:
                    ddlAvailableStructures.SelectedValue = "CODELIST";
                    break;
                case SdmxStructureEnumType.ConceptScheme:
                    ddlAvailableStructures.SelectedValue = "CONCEPT_SCHEME";
                    break;
                case SdmxStructureEnumType.CategoryScheme:
                    ddlAvailableStructures.SelectedValue = "CATEGORY_SCHEME";
                    break;
                case SdmxStructureEnumType.Dataflow:
                    ddlAvailableStructures.SelectedValue = "DATAFLOW";
                    break;
                case SdmxStructureEnumType.Dsd:
                    ddlAvailableStructures.SelectedValue = "KEY_FAMILY";
                    break;
                case SdmxStructureEnumType.AgencyScheme:
                    ddlAvailableStructures.SelectedValue = "AGENCY_SCHEME";
                    break;
                case SdmxStructureEnumType.DataProviderScheme:
                    ddlAvailableStructures.SelectedValue = "DATA_PROVIDER_SCHEME";
                    break;
                case SdmxStructureEnumType.DataConsumerScheme:
                    ddlAvailableStructures.SelectedValue = "DATA_CONSUMER_SCHEME";
                    break;
                case SdmxStructureEnumType.OrganisationUnitScheme:
                    ddlAvailableStructures.SelectedValue = "ORGANIZATION_UNIT_SCHEME";
                    break;
                case SdmxStructureEnumType.StructureSet:
                    ddlAvailableStructures.SelectedValue = "STRUCTURE_SET";
                    break;
                case SdmxStructureEnumType.ContentConstraint:
                    ddlAvailableStructures.SelectedValue = "CONTENT_CONSTRAINT";
                    break;
            }

            string structure = string.Format("{0}-{1}-{2}", cat.StructureReference.MaintainableId, cat.StructureReference.AgencyId, cat.StructureReference.Version);
            txtSelectedItem.Text = structure;

            Session["tmpCategoryReference"] = cat.CategoryReference.IdentifiableIds[0].ToString();
            Session["tmpCategorySchemeReference"] = string.Format("{0}-{1}-{2}", currentCategoryScheme.Id, currentCategoryScheme.AgencyId, currentCategoryScheme.Version);
            Session["tmpKindOfStructure"] = ddlAvailableStructures.SelectedValue;
            Session["tmpReferenceOfTheObject"] = structure;
            txtSelectedCategory.Visible = true;
            lblSelectedCategory.Visible = true;
            txtSelectedItem.Visible = true;
            lblSelectedItem.Visible = true;
            //===========================================
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CategoryMock"/> class.
 /// </summary>
 /// <param name="crossReference">
 /// The cross reference.
 /// </param>
 public CategoryMock(ICrossReference crossReference)
 {
     this._crossReference = crossReference;
     this._categorisation = this._crossReference.ReferencedFrom as ICategorisationObject;
 }