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);
        }
Exemplo n.º 2
0
 private string AppendClassificationCondition(string schema, bool childAsset)
 {
     if (ImacConstants.Add.Equals(schema))
     {
         return("asset.CLASSSTRUCTUREID in ({0})".Fmt(AssetConstants.Addclassifications));
     }
     if (ImacConstants.IsOtherSchema(schema))
     {
         return(AssetConstants.BuildOtherWhereClause(childAsset));
     }
     if (ImacConstants.IsLanSchema(schema))
     {
         return(AssetConstants.BuildPrinterWhereClause());
     }
     if (ImacConstants.IsStdSchema(schema))
     {
         //last classification is different for child installstd, monitors of a computer...
         return(AssetConstants.BuildStdWhereClause(childAsset));
     }
     return(null);
 }