public SearchRequestDto FilterAssets(AssociationPreFilterFunctionParameters parameters) { var filter = parameters.BASEDto; // Default filter to be applied to all Schemas filter.AppendSearchEntry("status", AssetConstants.Active, AssetConstants.Operating); filter.IgnoreWhereClause = true; // Add another filters depending on Schema var attributeHolder = parameters.OriginalEntity; var schemaId = parameters.Metadata.Schema.SchemaId; if ("printer".Equals(schemaId)) { filter.AppendSearchEntry(ISMConstants.PluspCustomerColumn, (string)attributeHolder.GetAttribute("printerpluspcustomer")); filter.AppendWhereClause(AssetConstants.BuildPrinterWhereClause()); } else if ("phone".Equals(schemaId)) { filter.AppendSearchEntry(ISMConstants.PluspCustomerColumn, (string)attributeHolder.GetAttribute("phonepluspcustomer")); filter.AppendSearchEntry(AssetConstants.ClassStructureIdColumn, AssetConstants.PhoneClassStructure); } else { var module = ContextLookuper.LookupContext().Module; if (module == null || !module.EqualsAny(FunctionalRole.AssetControl.GetName(), FunctionalRole.AssetRamControl.GetName())) { //if asset control, or asset ram control could be creating sr out of asset and this would make no sense filter.AppendSearchEntry(AssetConstants.CustodianColumn, SecurityFacade.CurrentUser(false).MaximoPersonId); } } return(filter); }
public HomeController(IConfigurationFacade facade, I18NResolver i18NResolver, ContextLookuper lookuper) { // _controllerFactory = (IAPIControllerFactory)GlobalConfiguration.Configuration.DependencyResolver.GetService(typeof(IAPIControllerFactory)); _facade = facade; _i18NResolver = i18NResolver; _lookuper = lookuper; }
public string GenerateUnionQueryCount(EntityMetadata entity, SearchRequestDto searchDTO) { var context = ContextLookuper.LookupContext(); var isTomOrItom = context.IsInModule(FunctionalRole.Itom) || context.IsInModule(FunctionalRole.Tom); if (isTomOrItom) { //HAP-805, tom or itom roles can see everything in the grid return(null); } return(_changeGridUnionQueryGenerator.GenerateQueryCount(entity, searchDTO)); }
private bool ShouldShowITC(InMemoryUser user) { var ctx = ContextLookuper.LookupContext(); //to avoid null references... var module = ctx.Module ?? ""; //var isFrThatHasNoAccess = module.EqualsAny(FunctionalRole.Tom.GetName(), FunctionalRole.Itom.GetName(), // FunctionalRole.Sso.GetName()); var isFrThatHasNoAccess = module.EqualsAny(FunctionalRole.Sso.GetName()); if (isFrThatHasNoAccess) { return(false); } return(user.HasProfile(ProfileType.Itc) || module.EqualsAny(FunctionalRole.XItc.GetName(), FunctionalRole.Tom.GetName(), FunctionalRole.Itom.GetName())); }
protected override ApplicationDetailResult GetApplicationDetail(ApplicationMetadata application, InMemoryUser user, DetailRequest request) { var isCreationFromAsset = request.InitialValues != null && request.InitialValues.ContainsAttribute("assetnum"); if (isCreationFromAsset) { //if the asset is pre selected, we need to determine the right schema out of it (either, printer,phone or general) application = DetermineSchemaFromAsset(request.InitialValues); AdjustInitialValues(request.InitialValues); } request.AssociationsToFetch = isCreationFromAsset ? "#all" : "fromlocation"; var result = base.GetApplicationDetail(application, user, request); if (isCreationFromAsset) { UpdateAssetDependants(application, result); } result.AllassociationsFetched = isCreationFromAsset; if (request.Id != null) { if (ContextLookuper.LookupContext().IsInModule(FunctionalRole.XItc) && !user.Genericproperties.ContainsKey(HapagPersonGroupConstants.HlagLocationXITCProperty)) { //HAP-1017 , for XITC we need to fill the list of "sub" locations so that these job plan actions of them become also available //TODO: move to a better place... var allGroups = LocationManager.GetLocationsOfLoggedUser(); var xitcgroups = new HashSet <string>(); foreach (var hlagGroupedLocation in allGroups) { var descriptions = hlagGroupedLocation.GetGroupDescriptions(); foreach (var description in descriptions) { xitcgroups.Add(description); } } user.Genericproperties[HapagPersonGroupConstants.HlagLocationXITCProperty] = xitcgroups; } //need to fill in service type from swdb } return(result); }
public IGenericResponseResult GetCompositionData(CompositionRequestWrapperDTO dto) { var user = SecurityFacade.CurrentUser(); if (null == user) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } var application = dto.Application; var request = dto.Request; var applicationMetadata = MetadataProvider.Application(application).ApplyPolicies(request.Key, user, ClientPlatform.Web); ContextLookuper.FillContext(request.Key); var compositionData = DataSetProvider .LookupDataSet(application) .GetCompositionData(applicationMetadata, request, dto.Data); return(compositionData); }
private IEnumerable <AttributeHolder> HandleITCReport(IEnumerable <AttributeHolder> resultObject, ApplicationMetadata application, PaginatedSearchRequestDto searchDto) { var user = SecurityFacade.CurrentUser(); var applicationSchemaKey = new ApplicationMetadataSchemaKey("itcreportregionandarea"); var complementApplicationMetadata = MetadataProvider.Application(application.Name).ApplyPolicies(applicationSchemaKey, user, ClientPlatform.Web); var complementSearchDTO = new PaginatedSearchRequestDto(); complementSearchDTO.SearchParams = searchDto.SearchParams.Replace("persongroup_.", "locationpersongroup_."); complementSearchDTO.SearchValues = searchDto.SearchValues; complementSearchDTO.SearchSort = searchDto.SearchSort; complementSearchDTO.ShouldPaginate = false; ContextLookuper.FillContext(applicationSchemaKey); var complementaryList = base.GetList(complementApplicationMetadata, complementSearchDTO); resultObject = resultObject.Union(complementaryList.ResultObject); foreach (var attributeHolder in resultObject) { try { var persongroup = attributeHolder.Attributes["persongroup"]; if (persongroup != null) { var groupDefault = attributeHolder.Attributes["groupdefault"]; if (persongroup.ToString().StartsWith(HapagPersonGroupConstants.BaseHapagLocationPrefix)) { attributeHolder.Attributes["itcrole"] = groupDefault.Equals(1) ? "Location ITC" : "Location ITC Delegate"; attributeHolder.Attributes["hlagsite"] = persongroup.ToString().Substring(HapagPersonGroupConstants.BaseHapagLocationPrefix.Length, 3); var persongroupdescription = attributeHolder.Attributes["persongroup_.description"]; if (persongroupdescription != null) { attributeHolder.Attributes["hlagcostcenter"] = persongroupdescription.ToString().Substring(persongroupdescription.ToString().LastIndexOf("-") + 1); var costcenterDescription = attributeHolder.Attributes["costcenterdescription"]; if (costcenterDescription != null) { attributeHolder.Attributes["hlagcostcenter"] += " // " + costcenterDescription; } } // Add blank fields just to match the second union iterator (Region and Area) attributeHolder.Attributes["locationcostcenterdescription"] = String.Empty; attributeHolder.Attributes["locationpersongroup_.persongroup"] = String.Empty; attributeHolder.Attributes["locationpersongroup_.description"] = String.Empty; } else if (persongroup.ToString().StartsWith(HapagPersonGroupConstants.BaseHapagAreaPrefix) || persongroup.ToString().StartsWith(HapagPersonGroupConstants.BaseHapagRegionPrefix)) { var locationpersongroup = attributeHolder.Attributes["locationpersongroup_.persongroup"]; attributeHolder.Attributes["hlagsite"] = locationpersongroup.ToString().Substring(HapagPersonGroupConstants.BaseHapagLocationPrefix.Length, 3); var locationpersongroupdescription = attributeHolder.Attributes["locationpersongroup_.description"]; if (locationpersongroupdescription != null) { attributeHolder.Attributes["hlagcostcenter"] = locationpersongroupdescription.ToString().Substring(locationpersongroupdescription.ToString().LastIndexOf("-") + 1); var locationcostcenterdescription = attributeHolder.Attributes["locationcostcenterdescription"]; if (locationcostcenterdescription != null) { attributeHolder.Attributes["hlagcostcenter"] += " // " + locationcostcenterdescription; } } if (persongroup.ToString().StartsWith(HapagPersonGroupConstants.BaseHapagAreaPrefix)) { attributeHolder.Attributes["itcrole"] = groupDefault.Equals(1) ? "Area ITC" : "Area ITC Delegate"; } else if (persongroup.ToString().StartsWith(HapagPersonGroupConstants.BaseHapagRegionPrefix)) { attributeHolder.Attributes["itcrole"] = groupDefault.Equals(1) ? "Region ITC" : "Region ITC Delegate"; } // Add blank fields just to match the first union iterator (Location) attributeHolder.Attributes["costcenterdescription"] = String.Empty; } } } catch (ArgumentOutOfRangeException ae) { } } return(resultObject.ToList()); }