public string DashboardIMACWhereClause() { var ctx = _contextLookuper.LookupContext(); var isViewAllOperation = ctx.ApplicationLookupContext != null && "list".Equals(ctx.ApplicationLookupContext.Schema); return(HapagQueryConstants.ITCOpenImacs(GetUserPersonGroupsUtils(true), isViewAllOperation)); }
public IGenericResponseResult Expand(InMemoryUser user, IDictionary <string, ApplicationCompositionSchema> compositionSchemas, CompositionExpanderHelper.CompositionExpansionOptions options) { var resultDict = new Dictionary <string, IEnumerable <IDictionary <string, object> > >(); var result = CompositionExpanderHelper.ParseDictionary(options.CompositionsToExpand); var printMode = _contextLookuper.LookupContext().PrintMode; foreach (var toExpand in result.DetailsToExpand) { var name = toExpand.Key; var compositionSchema = compositionSchemas[name]; var schema = compositionSchema.Schemas.Detail; if (printMode) { schema = compositionSchema.Schemas.Print; } var applicationMetadata = MetadataProvider.Application(EntityUtil.GetApplicationName(name)) .ApplyPolicies(schema.GetSchemaKey(), user, ClientPlatform.Web); var slicedEntityMetadata = MetadataProvider.SlicedEntityMetadata(applicationMetadata); var searchDTO = new SearchRequestDto(); searchDTO.AppendSearchParam(schema.IdFieldName); searchDTO.AppendSearchValue(toExpand.Value); var compositionExpanded = _entityRepository.GetAsRawDictionary(slicedEntityMetadata, searchDTO); resultDict.Add(name, compositionExpanded.ResultList); } return(new GenericResponseResult <Dictionary <string, IEnumerable <IDictionary <string, object> > > >(resultDict)); }
public string AssetWhereClauseFromLocations(HlagGroupedLocation[] locations) { var sb = new StringBuilder(); var isWWUser = SecurityFacade.CurrentUser().IsWWUser(); var ctx = _contextLookuper.LookupContext(); if (isWWUser && ctx.IsInModule(FunctionalRole.XItc) || (ctx.ApplicationLookupContext != null && "r0042ExportExcel".EqualsIc(ctx.ApplicationLookupContext.Schema))) { return("1=1"); } if (CollectionExtensions.IsNullOrEmpty(locations)) { //if u dont have any location you should not be able to see anything sb.Append("0=1"); return(sb.ToString()); } var i = 0; if (!(ctx.IsInModule(FunctionalRole.XItc) && isWWUser)) { //HAP-838 item 6, only XITC ww users should see it, or tom itom (who actually see asset) sb.AppendFormat("asset.status != '{0}' and ", AssetConstants.Decommissioned); } foreach (var location in locations) { if (i == 0) { sb.Append(" ( "); } i++; sb.Append(String.Format("(asset.pluspcustomer in ('{0}') and {1})", location.SubCustomer, location.CostCentersForQuery("asset.glaccount"))); if (i < locations.Count()) { sb.Append(" or "); } else { sb.Append(" ) "); } } return(sb.ToString()); }
public String ChangeGridQuery() { var user = SecurityFacade.CurrentUser(); 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); } var personGroupsForQuery = user.GetPersonGroupsForQuery(); return(String.Format(@" exists (select 1 from pmchgotherapprovers approvals_ where (wochange.wonum = approvals_.wonum) and approvals_.approvergroup IN ({0}) ) or exists (select 1 from WOACTIVITY as woactivity_ where wochange.wonum = woactivity_.parent and woactivity_.ownergroup in ({0}) )" , personGroupsForQuery)); }
protected override ApplicationDetailResult GetApplicationDetail(ApplicationMetadata application, InMemoryUser user, DetailRequest request) { var ctx = _context.LookupContext(); if (ctx.ApplicationLookupContext == null) { ctx.ApplicationLookupContext = new ApplicationLookupContext(); } ctx.ApplicationLookupContext.MetadataId = "changedetail"; return(base.GetApplicationDetail(application, user, request)); }
public WhereClauseResult Lookup(string applicationName, ApplicationLookupContext lookupContext = null) { var context = _contextLookuper.LookupContext(); if (lookupContext != null) { context.ApplicationLookupContext = lookupContext; } var resultString = _configurationService.Lookup <string>(String.Format(WcConfig, ConfigTypes.WhereClauses.GetRootLevel(), applicationName), context); return(BuildWhereClauseResult(resultString)); }
private string GetI18NLabel(ApplicationFieldDefinition applicationField, string schemaId) { var module = _contextLookuper.LookupContext().Module; if (module != null) { return(applicationField.Label); } var i18NKey = applicationField.ApplicationName + "." + applicationField.Attribute; var i18NValue = _i18NResolver.I18NValue(i18NKey, applicationField.Label, schemaId); return(i18NValue); }
public string GenerateQuery() { 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); } var externalTemplateIds = _changeWhereClauseProvider.GetTemplateIds(); var user = SecurityFacade.CurrentUser(); //force cache var personGroupsForQuery = user.GetPersonGroupsForQuery(); var extraUnions = NonTicketIdUnionQuery.Fmt(personGroupsForQuery); var completeUnionIdQuery = BaseIdWoChangeQuery.Fmt(externalTemplateIds, personGroupsForQuery, extraUnions); return("wochange.workorderid in ({0}) ".Fmt(completeUnionIdQuery)); }
protected override ApplicationDetailResult GetApplicationDetail(ApplicationMetadata application, InMemoryUser user, DetailRequest request) { //this means that we are creating the service request from an asset 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, application.Schema.SchemaId); request.AssociationsToFetch = "#all"; } if (application.Schema.SchemaId == "changedetail") { _contextLookuper.LookupContext().ApplicationLookupContext.MetadataId = "changedetail"; } var dbDetail = base.GetApplicationDetail(application, user, request); var resultObject = dbDetail.ResultObject; if (resultObject == null) { //it happens only if we´re pointint to a database different then the ws impl return(dbDetail); } if (application.Schema.SchemaId == "creationSummary") { HandleCreationSummary(resultObject); } var usefulFaqLinksUtils = GetUsefulFaqLinksUtils(application.Schema); if (usefulFaqLinksUtils.Count > 0) { HandleUsefulFaqLinks(resultObject, usefulFaqLinksUtils); } if (application.Schema.Mode == SchemaMode.input) { HandleAffectDateAndTime(resultObject, application); } else if (application.Schema.Mode == SchemaMode.output) { HandleClosedDate(resultObject, application); } dbDetail.AllassociationsFetched = isCreationFromAsset; return(dbDetail); }
public FileContentResult Export(string application, [FromUri] ApplicationMetadataSchemaKey key, [FromUri] PaginatedSearchRequestDto searchDTO, string module) { searchDTO.PageSize = searchDTO.TotalCount + 1; if (module != null) { _contextLookuper.LookupContext().Module = module; } var before = Stopwatch.StartNew(); var before2 = Stopwatch.StartNew(); var user = SecurityFacade.CurrentUser(); var applicationMetadata = MetadataProvider .Application(application) .ApplyPolicies(key, user, ClientPlatform.Web); var dataResponse = _dataController.Get(application, new DataRequestAdapter { Key = key, SearchDTO = searchDTO }); Log.Debug(LoggingUtil.BaseDurationMessageFormat(before, "finished gathering export excel data")); var excelBytes = _excelUtil.ConvertGridToExcel(user, applicationMetadata.Schema, ((ApplicationListResult)dataResponse).ResultObject); Log.Info(LoggingUtil.BaseDurationMessageFormat(before2, "finished export excel data")); var fileName = GetFileName(application, key.SchemaId) + ".xls"; var result = new FileContentResult(excelBytes, System.Net.Mime.MediaTypeNames.Application.Octet) { FileDownloadName = (string)StringUtil.FirstLetterToUpper(fileName) }; return(result); }
//Implements HAP-838 + HAP-1062 public string AssetWhereClauseIfRegionSelected() { var ctx = _contextLookuper.LookupContext(); var parameters = ctx.MetadataParameters; var sb = new StringBuilder(); if (ctx.IsInModule(FunctionalRole.XItc)) { // for xitc we need extra conditions sb.Append(_rooR0017WhereClauseProvider.AssetWhereClause()); } else if (!ctx.IsInAnyModule(FunctionalRole.Tom, FunctionalRole.Itom)) { //HAP-838 item 6, except for TOM,ITOM and XITC with WW no one should see these sb.Append("asset.status !='{0}'".Fmt(AssetConstants.Decommissioned)); } if (!HlagLocationUtil.ValidateRegionSelectionIsAllowed(ctx, SecurityFacade.CurrentUser()) || !parameters.ContainsKey("region")) { //no region selected return(sb.ToString()); } var parentRegion = parameters["region"]; try { var locations = _locationManager.FindLocationsOfParentLocation(new PersonGroup { Name = parentRegion }); ISet <string> subcustomers = new HashSet <string>(); foreach (var hlagGroupedLocation in locations) { //HAP-1062 --> appending only subcustomers, but disregarding costcenters subcustomers.Add(hlagGroupedLocation.SubCustomer); } if (!subcustomers.Any()) { //no subcustomer added to the query return(sb.ToString()); } if (sb.Length != 0) { sb.Append(" and "); } sb.Append(" asset.pluspcustomer in ( "); foreach (var subcustomer in subcustomers) { sb.Append("'").Append(subcustomer).Append("'").Append(","); } //removing last , and adding trailing parenthesis return(sb.ToString(0, sb.Length - 1) + ")"); } catch (Exception) { Log.WarnFormat("location {0} was not found", parentRegion); return(sb.ToString()); } }
protected virtual ApplicationListResult GetList(ApplicationMetadata application, PaginatedSearchRequestDto searchDto) { var totalCount = searchDto.TotalCount; IReadOnlyList <AttributeHolder> entities = null; var entityMetadata = MetadataProvider.SlicedEntityMetadata(application); var schema = application.Schema; searchDto.BuildProjection(schema); if (searchDto.Context != null && searchDto.Context.MetadataId != null) { searchDto.QueryAlias = searchDto.Context.MetadataId; } else { searchDto.QueryAlias = application.Name + "." + schema.SchemaId; } if (application.Schema.GetProperty("list.querygeneratorservice") != null) { searchDto.QueryGeneratorService = application.Schema.GetProperty("list.querygeneratorservice"); } if (schema.UnionSchema != null) { searchDto.BuildUnionDTO(searchDto, schema); } var propertyValue = schema.GetProperty(ApplicationSchemaPropertiesCatalog.ListSchemaOrderBy); if (searchDto.SearchSort == null && propertyValue != null) { //if the schema has a default sort defined, and we didn´t especifally asked for any sort column, apply the default schema searchDto.SearchSort = propertyValue; } var tasks = new Task[2]; var ctx = ContextLookuper.LookupContext(); //count query tasks[0] = Task.Factory.NewThread(c => { Quartz.Util.LogicalThreadContext.SetData("context", c); if (searchDto.NeedsCountUpdate) { Log.DebugFormat("BaseApplicationDataSet#GetList calling Count method on maximo engine. Application Schema \"{0}\" / Context \"{1}\"", schema, c); totalCount = _maximoConnectorEngine.Count(entityMetadata, searchDto); } }, ctx); //query tasks[1] = Task.Factory.NewThread(c => { Quartz.Util.LogicalThreadContext.SetData("context", c); // Only fetch the compositions schemas if indicated on searchDTO var applicationCompositionSchemata = new Dictionary <string, ApplicationCompositionSchema>(); var hasInlineComposition = schema.Compositions.Any(comp => comp.Inline); if ((searchDto.CompositionsToFetch != null && searchDto.CompositionsToFetch.Count > 0) || hasInlineComposition) { var allCompositionSchemas = CompositionBuilder.InitializeCompositionSchemas(schema); foreach (var compositionSchema in allCompositionSchemas) { if (compositionSchema.Value.INLINE || (searchDto.CompositionsToFetch != null && searchDto.CompositionsToFetch.Contains(compositionSchema.Key))) { applicationCompositionSchemata.Add(compositionSchema.Key, compositionSchema.Value); } } } Log.DebugFormat("BaseApplicationDataSet#GetList calling Find method on maximo engine. Application Schema \"{0}\" / Context \"{1}\"", schema, c); entities = _maximoConnectorEngine.Find(entityMetadata, searchDto, applicationCompositionSchemata); // Get the composition data for the list, only in the case of detailed list (like printing details), otherwise, this is unecessary if (applicationCompositionSchemata.Count > 0) { GetCompositionData(application, new PreFetchedCompositionFetchRequest(entities) { CompositionList = new List <string>(applicationCompositionSchemata.Keys) }, null); } }, ctx); Task.WaitAll(tasks); return(new ApplicationListResult(totalCount, searchDto, entities, schema)); }
public T Lookup <T>(string configKey) { var lookupContext = _contextLookuper.LookupContext(); return(_configService.Lookup <T>(configKey, lookupContext)); }