protected virtual ApplicationDetailResult GetApplicationDetail(ApplicationMetadata application, InMemoryUser user, DetailRequest request) { var id = request.Id; var entityMetadata = MetadataProvider.SlicedEntityMetadata(application); var applicationCompositionSchemas = CompositionBuilder.InitializeCompositionSchemas(application.Schema); DataMap datamap; if (id == null) { datamap = DefaultValuesBuilder.BuildDefaultValuesDataMap(application, request.InitialValues); } else { datamap = (DataMap) _maximoConnectorEngine.FindById(application.Schema, entityMetadata, id); if (datamap == null) { throw new InvalidOperationException("You donĀ“t have enough permissions to see that register. contact your administrator"); } var prefetchCompositions = "true".EqualsIc(application.Schema.GetProperty(ApplicationSchemaPropertiesCatalog.PreFetchCompositions)) || "#all".Equals(request.CompositionsToFetch); var compostionsToUse = new Dictionary <string, ApplicationCompositionSchema>(); foreach (var compositionEntry in applicationCompositionSchemas) { if (prefetchCompositions || FetchType.Eager.Equals(compositionEntry.Value.FetchType) || compositionEntry.Value.INLINE) { compostionsToUse.Add(compositionEntry.Key, compositionEntry.Value); } } if (compostionsToUse.Any()) { GetCompositionData(application, new PreFetchedCompositionFetchRequest(new List <AttributeHolder> { datamap }), null); } } var associationResults = BuildAssociationOptions(datamap, application, request); var detailResult = new ApplicationDetailResult(datamap, associationResults, application.Schema, applicationCompositionSchemas, id); return(detailResult); }
private void UpdateAssetDependants(ApplicationMetadata application, ApplicationDetailResult result) { var assetnum = result.ResultObject.GetAttribute("asset"); var relatedAsset = result.AssociationOptions["asset_"].AssociationData.FirstOrDefault(a => a.Value.Equals(assetnum)); if (relatedAsset != null) { //fill object with the entire extraprojection fields result.ResultObject.SetAttribute("asset_", relatedAsset); var multiValueAssociationOption = (MultiValueAssociationOption)relatedAsset; result.ResultObject.SetAttribute("asset_.location", multiValueAssociationOption.Extrafields["location"]); if (multiValueAssociationOption.Extrafields.ContainsKey("primaryuser_.personid")) { result.ResultObject.SetAttribute("asset_.primaryuser_.personid", multiValueAssociationOption.Extrafields["primaryuser_.personid"]); } } //look for any dependencies from the location field, this simulates the code dispatched when the user changes the location on the screen var locationDependentas = DoUpdateAssociation(application, new AssociationUpdateRequest { TriggerFieldName = "fromlocation" }, result.ResultObject); foreach (var dependants in locationDependentas) { if (result.AssociationOptions.ContainsKey(dependants.Key)) { result.AssociationOptions.Remove(dependants.Key); } result.AssociationOptions[dependants.Key] = dependants.Value; } var assetDependants = DoUpdateAssociation(application, new AssociationUpdateRequest { TriggerFieldName = "asset" }, result.ResultObject); foreach (var dependants in assetDependants) { if (result.AssociationOptions.ContainsKey(dependants.Key)) { result.AssociationOptions.Remove(dependants.Key); } result.AssociationOptions[dependants.Key] = dependants.Value; } }