/// <summary> /// Initializes a new instance of the <see cref="CommonFileStoreRowViewModel"/> class /// </summary> /// <param name="store">The associated <see cref="CommonFileStore"/></param> /// <param name="session">The <see cref="ISession"/></param> /// <param name="containerViewModel">The container view-model</param> public CommonFileStoreRowViewModel(CommonFileStore store, ISession session, IViewModelBase <Thing> containerViewModel) : base(store, session, containerViewModel) { this.folderCache = new Dictionary <Folder, FolderRowViewModel>(); this.fileCache = new Dictionary <File, FileRowViewModel>(); this.UpdateProperties(); }
public void SetUp() { this.session = new Mock <ISession>(); this.person = new Person(Guid.NewGuid(), this.cache, this.uri) { ShortName = "person", GivenName = "John", Surname = "Doe" }; this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri) { Person = this.person, IsActive = true, }; this.store = new CommonFileStore(Guid.NewGuid(), this.cache, this.uri); this.store = new CommonFileStore(Guid.NewGuid(), this.cache, this.uri); this.file = new File(Guid.NewGuid(), this.cache, this.uri); this.fileRevision1 = new FileRevision(Guid.NewGuid(), this.cache, this.uri) { Name = "1", Creator = this.participant, CreatedOn = new DateTime(1, 1, 1) }; this.fileRevision2 = new FileRevision(Guid.NewGuid(), this.cache, this.uri) { Name = "1.1", Creator = this.participant, CreatedOn = new DateTime(1, 1, 2) }; }
public void SetUp() { this.fileRevisionRuleChecker = new FileRevisionRuleChecker(); this.modelReferenceDataLibrary = new ModelReferenceDataLibrary(); this.engineeringModelSetup = new EngineeringModelSetup(); this.engineeringModel = new EngineeringModel(); this.commonFileStore = new CommonFileStore(); this.file = new File(); this.fileRevision = new FileRevision(); this.engineeringModelSetup.RequiredRdl.Add(this.modelReferenceDataLibrary); this.engineeringModel.EngineeringModelSetup = this.engineeringModelSetup; this.engineeringModel.CommonFileStore.Add(commonFileStore); this.commonFileStore.File.Add(this.file); this.file.FileRevision.Add(this.fileRevision); }
/// <summary> /// Serialize the <see cref="CommonFileStore"/> /// </summary> /// <param name="commonFileStore">The <see cref="CommonFileStore"/> to serialize</param> /// <returns>The <see cref="JObject"/></returns> private JObject Serialize(CommonFileStore commonFileStore) { var jsonObject = new JObject(); jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), commonFileStore.ClassKind))); jsonObject.Add("createdOn", this.PropertySerializerMap["createdOn"](commonFileStore.CreatedOn)); jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](commonFileStore.ExcludedDomain.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](commonFileStore.ExcludedPerson.OrderBy(x => x, this.guidComparer))); jsonObject.Add("file", this.PropertySerializerMap["file"](commonFileStore.File.OrderBy(x => x, this.guidComparer))); jsonObject.Add("folder", this.PropertySerializerMap["folder"](commonFileStore.Folder.OrderBy(x => x, this.guidComparer))); jsonObject.Add("iid", this.PropertySerializerMap["iid"](commonFileStore.Iid)); jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](commonFileStore.ModifiedOn)); jsonObject.Add("name", this.PropertySerializerMap["name"](commonFileStore.Name)); jsonObject.Add("owner", this.PropertySerializerMap["owner"](commonFileStore.Owner)); jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](commonFileStore.RevisionNumber)); jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](commonFileStore.ThingPreference)); return(jsonObject); }
/// <summary> /// Persist the DTO composition to the ORM layer. /// </summary> /// <param name="transaction"> /// The transaction object. /// </param> /// <param name="partition"> /// The database partition (schema) where the requested resource will be stored. /// </param> /// <param name="commonFileStore"> /// The commonFileStore instance to persist. /// </param> /// <returns> /// True if the persistence was successful. /// </returns> private bool CreateContainment(NpgsqlTransaction transaction, string partition, CommonFileStore commonFileStore) { var results = new List <bool>(); foreach (var folder in this.ResolveFromRequestCache(commonFileStore.Folder)) { results.Add(this.FolderService.CreateConcept(transaction, partition, folder, commonFileStore)); } foreach (var file in this.ResolveFromRequestCache(commonFileStore.File)) { results.Add(this.FileService.CreateConcept(transaction, partition, file, commonFileStore)); } return(results.All(x => x)); }
public void Setup() { this.session = new Mock <ISession>(); this.panelNavigationService = new Mock <IPanelNavigationService>(); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.permissionService = new Mock <IPermissionService>(); this.dialogNavigationService = new Mock <IDialogNavigationService>(); this.fileDialogService = new Mock <IOpenSaveFileDialogService>(); this.serviceLocator = new Mock <IServiceLocator>(); ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object); this.serviceLocator.Setup(x => x.GetInstance <IOpenSaveFileDialogService>()).Returns(this.fileDialogService.Object); this.assembler = new Assembler(this.uri); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.sitedir = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri); this.engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "model" }; this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri) { ShortName = "person", GivenName = "person", }; this.participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri) { Person = this.person, IsActive = true, }; this.domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "domain", ShortName = "d" }; this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri); this.mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri) { RequiredRdl = this.srdl }; this.sitedir.Model.Add(this.engineeringModelSetup); this.engineeringModelSetup.IterationSetup.Add(this.iterationSetup); this.sitedir.Person.Add(this.person); this.sitedir.Domain.Add(this.domain); this.engineeringModelSetup.RequiredRdl.Add(this.mrdl); this.sitedir.SiteReferenceDataLibrary.Add(this.srdl); this.engineeringModelSetup.Participant.Add(this.participant); this.participant.Domain.Add(this.domain); this.model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri) { EngineeringModelSetup = this.engineeringModelSetup }; this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri) { IterationSetup = this.iterationSetup }; this.model.Iteration.Add(this.iteration); this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); this.session.Setup(x => x.OpenIterations) .Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domain, this.participant) } }); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.store = new CommonFileStore(Guid.NewGuid(), this.assembler.Cache, this.uri); this.folder1 = new Folder(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "1", CreatedOn = new DateTime(1, 1, 1), Creator = this.participant }; this.folder2 = new Folder(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "2", CreatedOn = new DateTime(1, 1, 1), Creator = this.participant }; this.file = new File(Guid.NewGuid(), this.assembler.Cache, this.uri); this.fileRevision1 = new FileRevision(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "1", Creator = this.participant, CreatedOn = new DateTime(1, 1, 1) }; this.fileRevision2 = new FileRevision(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "1", Creator = this.participant, CreatedOn = new DateTime(1, 1, 2) }; }
/// <summary> /// Add an Common File Store row view model to the list of <see cref="CommonFileStore"/> /// </summary> /// <param name="commonFileStore"> /// The <see cref="CommonFileStore"/> that is to be added /// </param> private CommonFileStoreRowViewModel AddCommonFileStoreRowViewModel(CommonFileStore commonFileStore) { return(new CommonFileStoreRowViewModel(commonFileStore, this.Session, this)); }
public void Setup() { this.assembler = new Assembler(this.uri); this.session = new Mock <ISession>(); this.session.Setup(x => x.Assembler).Returns(this.assembler); var dal = new Mock <IDal>(); dal.Setup(x => x.IsReadOnly).Returns(false); this.session.Setup(x => x.Dal).Returns(dal.Object); this.sitedir = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri); this.domain1 = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri); this.domain2 = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri); this.personRole = new PersonRole(Guid.NewGuid(), this.assembler.Cache, this.uri); this.participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri); this.participantRole = new ParticipantRole(Guid.NewGuid(), this.assembler.Cache, this.uri); this.model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri) { EngineeringModelSetup = this.modelsetup }; this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri) { IterationSetup = this.iterationSetup }; this.definition = new Definition(Guid.NewGuid(), this.assembler.Cache, this.uri); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri); this.booleanpt = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri); this.person2 = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri); this.elementDef = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri); this.relationship = new BinaryRelationship(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri); this.valueset = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri); this.requirementsSpecification = new RequirementsSpecification(Guid.NewGuid(), this.assembler.Cache, this.uri); this.requirement = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri); this.commonFileStore = new CommonFileStore(Guid.NewGuid(), this.assembler.Cache, this.uri); this.sitedir.Model.Add(this.modelsetup); this.sitedir.Person.Add(this.person); this.sitedir.Person.Add(this.person2); this.sitedir.PersonRole.Add(this.personRole); this.sitedir.Domain.Add(this.domain1); this.sitedir.Domain.Add(this.domain2); this.modelsetup.IterationSetup.Add(this.iterationSetup); this.modelsetup.Participant.Add(this.participant); this.sitedir.ParticipantRole.Add(this.participantRole); this.model.Iteration.Add(this.iteration); this.person.Role = this.personRole; this.participant.Person = this.person; this.participant.Role = this.participantRole; this.participant.Domain.Add(this.domain1); this.modelsetup.Definition.Add(this.definition); this.sitedir.SiteReferenceDataLibrary.Add(this.srdl); this.srdl.ParameterType.Add(this.booleanpt); this.iteration.Element.Add(this.elementDef); this.iteration.Relationship.Add(this.relationship); this.elementDef.Parameter.Add(this.parameter); this.parameter.ValueSet.Add(this.valueset); this.modelsetup.EngineeringModelIid = this.model.Iid; this.iterationSetup.IterationIid = this.iteration.Iid; this.elementDef.Owner = this.domain1; this.relationship.Owner = this.domain1; this.parameter.Owner = this.domain1; this.requirementsSpecification.Requirement.Add(this.requirement); this.iteration.RequirementsSpecification.Add(this.requirementsSpecification); this.model.CommonFileStore.Add(this.commonFileStore); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domain1, this.participant) } }); this.permissionService = new PermissionService(this.session.Object); }