BeanIO how to skip/filter #Group in fixedLength - bean-io

I'm trying to read a fixedlength file.
I want to extract list of Document, but filtered only with RecordHeader (RH) with field value "BB".
So skip Document with recordHeader equals:
RH20210607AA
This is an example of my class Document
#Group
public class Document{
#Record(order = 1, minOccurs=1, maxOccurs=1)
private RH recordHeader;
#Record(order = 2, minOccurs=1, maxOccurs = -1, type=RD.class, collection = List.class)
private List<RD> recordDetails;
}
This is an example of my class RH
#Record
public class RH{
#Field(ordinal = 0, required = true, length = 2, align = Align.LEFT, rid = true, literal = "RH")
private String recordType;
#Field(ordinal = 1, required = true, length=8, format = "yyyyMMdd")
private LocalDate documentDate;
#Field(ordinal = 2, required = true, length = 2, padding = ' ', align = Align.LEFT)
private String documentCode;
}
This is an example of fixedLength file:
fake
Unknown record
Unknown record
RH20210607AA
RDitem1
RDitem2
Unknown record
RH20210607BB
RDitem2
RDitem3
Unknown record
Unknown record
Unknown record
RH20210607BB
RDitem1
RDitem4
RDitem5
Thanks for help

You can use more than one field on your RH class to identify the records you want. You can do this:
#Record
public class RH {
#Field(ordinal = 0, required = true, length = 2, align = Align.LEFT, rid = true, literal = "RH")
private String recordType;
#Field(ordinal = 1, required = true, length = 8, format = "yyyyMMdd")
private Date documentDate;
#Field(ordinal = 2, required = true, length = 2, padding = ' ', align = Align.LEFT, rid = true, literal = "BB")
private String documentCode;
}
Note the extra attributes on the #Field annotation for the documentCode field --> rid = true, literal = "BB"
You can use a regular expression in place of the literal = "BB" if you need to include more RH records or use it as an exclusion filter.
You are probably already doing it, you also need to configure the StreamFactory to ignore unidentifiable records:
final StreamBuilder builder = new StreamBuilder("streamName")
.readOnly()
.format("fixedlength")
.parser(new FixedLengthParserBuilder())
.ignoreUnidentifiedRecords() // <-- important
.addGroup(...)
.addRecord(RD.class));
factory.define(builder);

Related

How to send emails based on data filled in a form?

function ifstatement() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const ws = ss.getSheetByName("Product Form");
const ws2 = ss.getSheetByName("Email details");
var Avals = ws.getRange("c1:c").getValues();
var lr = Avals.filter(String).length;
Logger.log(lr);
var recipient = ws.getRange(lr,2).getValue();
var sub = ws.getRange(lr,4).getValue();
var mailTemp = ws.getRange(lr,5).getValue();
var impfield1 = ws.getRange(lr,6).getValue();
var impfield2 = ws.getRange(lr,8).getValue();
var impfield3 = ws.getRange(lr,10).getValue();
var fieldvalue1 = ws.getRange(lr,7).getValue();
var fieldvalue2 = ws.getRange(lr,9).getValue();
var fieldvalue3 = ws.getRange(lr,11).getValue();
var heading = ws.getRange(lr,12).getValue();
var subheading = ws.getRange(lr,13).getValue();
var body = ws.getRange(lr,14).getValue();
var footer = ws.getRange(lr,15).getValue();
var attach = ws.getRange(lr,17).getValue();
var tomail = ws.getRange(lr,16).getValue();
var file1 = attach.split(",").map(url => DriveApp.getFileById(url.trim().split("=")[1]).getBlob());
var AvalsWealth = ws2.getRange("b1:b").getValues();
var AvalsInsurance = ws2.getRange("c1:c").getValues();
var AvalsTeam = ws2.getRange("e1:e").getValues();
var lrWealth = AvalsWealth.filter(String).length;
var lrInsurance = AvalsInsurance.filter(String).length;
var lrTeam = AvalsTeam.filter(String).length;
Logger.log(mailTemp);
Logger.log(heading);
if(tomail=="Wealth RMs"){
var bccmail = ws2.getRange(2,2,lrWealth).getValues().toString();
} else if(tomail=="Self"){
var bccmail = recipient;
} else if(tomail=="Insurance RMs"){
var bccmail = ws2.getRange(2,3,lrInsurance).getValues().toString();
} else if(tomail=="All India"){
var bccmail = ws2.getRange(2,4,lrTeam).getValues().toString();
}
Logger.log(bccmail)
if(mailTemp=="HTML1"){
const htmlTemplate = HtmlService.createTemplateFromFile("HTML1");
htmlTemplate.heading = heading;
htmlTemplate.subheading = subheading;
htmlTemplate.body = body;
htmlTemplate.footer = footer;
htmlTemplate.impfield1 = impfield1;
htmlTemplate.impfield2 = impfield2;
htmlTemplate.impfield3 = impfield3;
htmlTemplate.fieldvalue1 = fieldvalue1;
htmlTemplate.fieldvalue2 = fieldvalue2;
htmlTemplate.fieldvalue3 = fieldvalue3;
const htmlforemail = htmlTemplate.evaluate().getContent();
GmailApp.sendEmail('',
""+ sub + "",
'',
{htmlBody: htmlforemail,
bcc: bccmail,
attachments: file1}
) } else if(mailTemp=="HTML2"){
const htmlTemplate = HtmlService.createTemplateFromFile("HTML2");
htmlTemplate.heading = heading;
htmlTemplate.subheading = subheading;
htmlTemplate.body = body;
htmlTemplate.footer = footer;
htmlTemplate.impfield1 = impfield1;
htmlTemplate.impfield2 = impfield2;
htmlTemplate.impfield3 = impfield3;
htmlTemplate.fieldvalue1 = fieldvalue1;
htmlTemplate.fieldvalue2 = fieldvalue2;
htmlTemplate.fieldvalue3 = fieldvalue3;
const htmlforemail = htmlTemplate.evaluate().getContent();
GmailApp.sendEmail('',
""+ sub + "",
'',
{htmlBody: htmlforemail,
bcc: bccmail,
attachments: file1}
) } else if(mailTemp=="HTML3"){
const htmlTemplate = HtmlService.createTemplateFromFile("AUM Annual awards");
htmlTemplate.heading = heading;
htmlTemplate.subheading = subheading;
htmlTemplate.body = body;
htmlTemplate.footer = footer;
htmlTemplate.impfield1 = impfield1;
htmlTemplate.impfield2 = impfield2;
htmlTemplate.impfield3 = impfield3;
htmlTemplate.fieldvalue1 = fieldvalue1;
htmlTemplate.fieldvalue2 = fieldvalue2;
htmlTemplate.fieldvalue3 = fieldvalue3;
const htmlforemail = htmlTemplate.evaluate().getContent();
GmailApp.sendEmail('',
""+ sub + "",
'',
{htmlBody: htmlforemail,
bcc: bccmail}
) } else if(mailTemp=="HTML4"){
const htmlTemplate = HtmlService.createTemplateFromFile("HTML4");
htmlTemplate.heading = heading;
htmlTemplate.subheading = subheading;
htmlTemplate.body = body;
htmlTemplate.footer = footer;
htmlTemplate.impfield1 = impfield1;
htmlTemplate.impfield2 = impfield2;
htmlTemplate.impfield3 = impfield3;
htmlTemplate.fieldvalue1 = fieldvalue1;
htmlTemplate.fieldvalue2 = fieldvalue2;
htmlTemplate.fieldvalue3 = fieldvalue3;
const htmlforemail = htmlTemplate.evaluate().getContent();
GmailApp.sendEmail('mayank.agarwal#aumcap.com',
""+ sub + "",
'',
{htmlBody: htmlforemail,
bcc: bccmail,
attachments: file1}
) }
}
I have this small setup where I have a Google Sheet, Google Appscript and Google form.
The user needs to input data in a Google Form - and once the sheet (linked with Form response) receives the updated row - a script is triggered which takes the data from the row and feeds it into the sheet and sends mail to the selected set of users.
Now the problem I am facing is that I need to send this mail to approx 100-150 people, however Googel appscript does not allow me to send mail to more than 30 participants at a time.
I understand that I need an Email service for this, however, I am unable to find any good solution wherein I can store my templates and the user just fills up data fields and shoots the mail.
Maybe because I am very new to this tech field so thats why.
Can anyone please guide me as to what is the setup I need to use for my purpose?
Thanks!
The first thing you need to do is to keep the BCC list as an array until it's necessary. This will allow us to make chunks out of it. This means removing the .toString() at the end of assigning bccmail.
Then, we need a custom function to send the email in batches of emails. I'm calling that function sendMassEmail.
function sendMassEmail(bccList, subject, plainBody, htmlBody, attachments) {
for (let bcc of chunks(bccList, 30)) {
GmailApp.sendEmail(
'',
subject,
plainBody,
{
htmlBody,
bcc: bcc.join(','),
attachments,
},
)
}
}
Chunks is a function that does exactly that, gets the elements of an array in chunks. My favorite implementation for this case is by using a generator.
I've kept the plain text body as it's important to generate it if you are sending it, as it is shown in most clients on the Inbox. Also, some of them can only read this ones (think smart watch).
The last argument (attachments) is optional.
Here is an example on how you would use it:
sendMassEmail(
bccmail,
sub.toString(),
'', // Should probably change it
htmlforemail,
file1,
)
Note that it's better to use toString() than concatenating into an empty string.
References
GmailApp.sendEmail(recipient, subject, body, options) (Apps Script reference)
for..of (MDN JavaScript reference)
Functions (MDN JavaScript guide)
Split array into chunks (StackOverflow question)

Swagger / springfox generating response example automatically

Currently using springfox 2.9.2 to Swagger document an API created in Spring.
I want to add example response in the documentation, like in this image;
my understanding is that I can do something similar to this:
#ApiResponses(value = {
#ApiResponse(code = 200, message = "Success",
examples = #io.swagger.annotations.Example(
value = {
#ExampleProperty(value = "{'snapshot':{'type': 'AAA'}}", mediaType = "application/json")
}))
I'm placing this code snippet just above the GET method in this case.
unfortunately the 2 examples above always shows : identifier expected error
But I also see that I can do this too:
#ApiResponses(value = {
ApiResponse(code = 200, message = "Success", response = MyModel.class,
)
})
Also I see that I can add an example with #ApiOperation level:
#ApiOperation(value = "Create a Account", nickname = "createAccount", notes = "Create a account", response = AccountResponse.class, tags={ })
My questions are:
How can I add an example JSON response to my Swagger documentation?
It would be ideal to just point Swagger/Springfox to my model/bean and have it generate the example response automatically, and automatically update with each update for the bean/model. Is this what the second code snippet above is supposed to do?
Define example with annotation for dto:
#ApiModel("Crop")
public class CropDto {
#ApiModelProperty(name = "Unique guid", position = 1, example = "7aaee0e2-6884-4fd7-ba63-21d76723dce2")
public UUID id;
#ApiModelProperty(name = "Unique code", position = 2, example = "squ")
public String code;
#ApiModelProperty(name = "Unique name", position = 3, example = "Squash")
public String name;
#ApiModelProperty(position = 4, example = "Cucurbita pepo L.")
public String description;
}

Blank results while using Tokens Regex rules to identify Named Entities

I am struggling with writing the correct rule which involves macros to identify organizations in a text.
To Identify Matrix Inc. in:
With it's rising share prices Matrix Inc. has come out a winner this quarter.
I am trying to check for words like Inc within the entity and thus defined a macros and rule as below:
$ORGANIZATION_TITLES = "/pharmaceuticals?|group|corp|corporation|international|co.?|inc.?|incorporated|holdings|motors|ventures|parters|llc|limited liability corporation|pvt.? ltd.?/"
ENV.defaults["stage"] = 1
{
ruleType: "tokens",
pattern: ([$ORGANIZATION_TITLES]),
action: ( Annotate($0, ner, "ORGANIZATION") )
}
ENV.defaults["stage"] = 2
{ ( [{tag:NNP}]+? ($ORGANIZATION_TITLES)) => ORGANIZATION }
I tried using bindings also and then applying the rule.
env.bind("$ORGANIZATION_TITLES", TokenSequencePattern.compile(env,"/pharmaceuticals?|group|corp|corporation|international|co.?|inc.?|incorporated|holdings|motors|ventures|parters|llc|limited liability corporation|pvt.? ltd.?/"));
Nothing seems to be working. I need to define more complex pattern rules involving macros like:
pattern: ( [ { ner:PERSON } ]+ /,/*? ($TITLES_CORPORATE_PREFIXES)*? $TITLES_CORPORATE+? /,/*? /of|for/? /,/*? [ { ner:ORGANIZATION } ]+ )
where $TITLES_CORPORATE_PREFIXES and $TITLES_CORPORATE are macros similar to $ORGANIZATION_TITLES.
What am I doing wrong?
EDIT
Here's my code:
public static void main(String[] args)
{
String rulesFile = "D:\\Workspace\\resource\\NERRulesFile.txt";
String dataFile = "D:\\Workspace\\resource\\GoldSetSentences.txt";
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
// pipeline.addAnnotator(new TokensRegexAnnotator(rulesFile));
String inputText = "Bill Edelman , CEO and Chairman , for Paragonix commented on the Supply Agreement with Essential Pharmaceuticals .";
Annotation document = new Annotation(inputText.toLowerCase());
pipeline.annotate(document);
List<CoreMap> sentences = document.get(SentencesAnnotation.class);
CoreMapExpressionExtractor extractor = CoreMapExpressionExtractor.createExtractorFromFiles(TokenSequencePattern.getNewEnv(), rulesFile);
/* Next we can go over the annotated sentences and extract the annotated words,
Using the CoreLabel Object */
for (CoreMap sentence : sentences)
{
List<MatchedExpression> matched = extractor.extractExpressions(sentence);
for(MatchedExpression phrase : matched){
// Print out matched text and value
System.out.println("matched: " + phrase.getText() + " with value " + phrase.getValue());
// Print out token information
CoreMap cm = phrase.getAnnotation();
for (CoreLabel token : cm.get(TokensAnnotation.class))
{
String word = token.get(TextAnnotation.class);
String lemma = token.get(LemmaAnnotation.class);
String pos = token.get(PartOfSpeechAnnotation.class);
String ne = token.get(NamedEntityTagAnnotation.class);
System.out.println("matched token: " + "word="+word + ", lemma="+lemma + ", pos=" + pos + "ne=" + ne);
}
}
}
}
Here is a rules file that should work:
ner = { type: "CLASS", value: "edu.stanford.nlp.ling.CoreAnnotations$NamedEntityTagAnnotation" }
$ORGANIZATION_TITLES = "/inc\.|corp\./"
{ pattern: ([{pos: NNP}]+ $ORGANIZATION_TITLES), action: ( Annotate($0, ner, "RULE_FOUND_ORG") ) }
I have made some changes to our code base to make the TokensRegexAnnotator more easily accessible. You will need to get the latest version from GitHub: https://github.com/stanfordnlp/CoreNLP
java -Xmx8g edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,tokensregex -tokensregex.rules organization.rules -file samples.txt -outputFormat text -tokensregex.caseInsensitive
If you run this command or the equivalent Java API call it should work:

Java 3 Hashing Programme

The directions in this section of code are giving me trouble and I don't know how to follow through with them properly. (We have to write code where there are dollar signs.)
Instructions: write a code that repetitively invokes the HashPerformanceClass mainDriver. Then the repetitive code starts the number of insertions at statrInsertions, increase the insert count by the deltaInsertions until end insertions value.
Problem
I am having trouble repetitively invoking the HashPerformanceClass mainDriver, and I don't know what to do. If anyone has any advise I would be grateful.
public class MainClass {
static int displayResultsNo = 0;
void displayHashResults() {
displayResultsNo++;
System.out.println("\nDisplay No. - "+displayResultsNo);
System.out.println("\n\nHash Instrumented Performance:\n-----------------------------");
System.out.println("Trials: " + HashPerformanceClass.trials + ", " +
"Insert Count: " + HashPerformanceClass.insertCount + ", " +
"Load: " + HashPerformanceClass.payload + ", " +
"Table Start Size: " + HashPerformanceClass.startingSize);
System.out.println("\nLinear Hashing:");
System.out.println("Insertion Total Probes: " + HashPerformanceClass.insertionLinearProbes) ;
System.out.println("Insertion Average Probes: " + HashPerformanceClass.insertionLinearProbesAvg);
System.out.println("\nDouble Hashing:");
System.out.println("Insertion Total Probes: " + HashPerformanceClass.insertionDoubleProbes) ;
System.out.println("Insertion Average Probes: " + HashPerformanceClass.insertionDoubleProbesAvg);
System.out.println("\nPerfect Hashing:");
System.out.println("Insertion Total Probes: " + HashPerformanceClass.insertionPerfectProbes) ;
System.out.println("Insertion Average Probes: " + HashPerformanceClass.insertionPerfectProbesAvg);
}//displayHashResults()
static int displayNo = 0;
void displayHashAvgProbesTable(int trials, int startInsertions, int endInsertions, int deltaInsertions, double load, int startSize) {
displayNo++;
System.out.println("\n\nDisplay No. - "+displayNo);
System.out.println("\nAverage Number of Probes Table \n------------------------------\ntrials: "+trials+" Load: "+load+" Start Size: "+startSize+"\n");
System.out.println(String.format("%-15s %-15s %-15s %-15s", "No Of Items","Linear Hash" ,"Double Hash" ,"Perfect Hash ") );
System.out.println(String.format("%-15s %-15s %-15s %-15s", "Inserted" ,"Probe Average","Probe Average","Probe Average") );
System.out.println(String.format("%-15s %-15s %-15s %-15s", "-----------","-------------","-------------","-------------") );
//$ write a code that repetitively invokes the HashPerformanceClass mainDriver
// The the repetitive code starts the number of insertions at startInsertions, increases the insert count by the deltaInsertions
//until end insertions value
}//displayHashAvgProbesTable()
MainClass () {
//$Invoke HashPerformanceClass mainDriver using arguments of insertCount=1, trials =10, payLoad=100%, Starting Size =7, display results
HashPerformanceClass.mainDriver( 1, 1, 1.0, 7); displayHashResults();
HashPerformanceClass.mainDriver(100, 80, 0.5, 101); displayHashResults(); //third column 1.0 = 100%
HashPerformanceClass.mainDriver(100, 80, 0.9, 101); displayHashResults();
HashPerformanceClass.mainDriver( 20, 1000, 0.5, 503); displayHashResults();
HashPerformanceClass.mainDriver( 20, 1000, 1.0, 1009); displayHashResults();
HashPerformanceClass.mainDriver( 20, 1000, 1.0, 4999); displayHashResults();
HashPerformanceClass.mainDriver(100, 2400, 0.5, 4999); displayHashResults();
displayHashAvgProbesTable ( 10, 100, 2000, 100, 0.5, 1009);
displayHashAvgProbesTable ( 10, 100, 2500, 1000, 0.5, 4999);
displayHashAvgProbesTable ( 10, 100, 2500, 1000, 0.5, 4999);
}//MainClass
public static void main(String[] args) {
new MainClass();
}//main()
}//MainClass
___________________________________________________________
import java.util.*;
/**
* A class for generating statistical information hash table insertion.
*/
public class HashPerformanceClass {
static int insertionLinearProbes = 0, insertionDoubleProbes = 0, insertionPerfectProbes = 0;
static float insertionLinearProbesAvg = 0, insertionDoubleProbesAvg = 0, insertionPerfectProbesAvg = 0;
static int trials;
static int insertCount;
static double payload;
static int startingSize;
public static void mainDriver(int trials, int insertCount, double payLoad, int startingSize) {
HashPerformanceClass.trials = trials;
HashPerformanceClass.insertCount = insertCount;
HashPerformanceClass.payload = payLoad;
HashPerformanceClass.startingSize= startingSize;
insertionLinearProbes = insertionDoubleProbes = insertionPerfectProbes = 0;
insertionLinearProbesAvg = insertionDoubleProbesAvg = insertionPerfectProbesAvg = 0;
//$ Declare all 3 hash table objects (linear, double, perfect) using the generic parameterized types as String and setting Starting Size from the mainDriver input parameter
DictionaryInstrumentedLinearImplementation <String, String> linearHashTableObj;
DictionaryInstrumentedDoubleImplementation <String, String> doubleHashTableObj;
DictionaryInstrumentedPerfectImplementation<String, String> perfectHashTableObj;
//Array used to hold random data inserted
String dataArray[];
//$
//For each trial set the inputs for the hash table Implementation
// Generate the Random Data array using insert count, do only once for each trial so that all hash table types have same source data set
// For all 3 hash table types
// Instantiate new hash table object
// Set the pay load factor hashtableobject.set payload
// Insert all the data from the array into the table insertalldata( , );
// Reset the probe counters for the hash table insertionlinear probes +=
// Sum up the probe statistics
//do this for all insertionlinearprobes double and perfect . . .
//$ Calculate all the insertion probes averages into the class variables for each hash type
}//mainDriver()
/* Generate an array of random of pseudo words. Each word will be composed of three randomly chosen syllables.
* #param arraySize The number of strings to generate.
* #return The array of strings.
*/
private static String[] generateRandomData(int arraySize) {
String uniqueWordStringArray[] = new String[arraySize];
DictionaryInstrumentedLinearImplementation<String,String> checkTable = new DictionaryInstrumentedLinearImplementation<String,String>();
String firstSylStringArray [] = {"ther", "fal", "sol", "cal", "com", "don", "gan", "tel", "fren", "ras", "tar", "men", "tri", "cap", "har"};
String secondSylStringArray[] = {"mo", "ta", "ra", "te", "bo", "bi", "du", "ca", "dan", "sen", "di", "no", "fe", "mi", "so" };
String thirdSylStringArray [] = {"tion", "ral", "tal", "ly", "nance", "tor", "ing", "ger", "ten", "ful", "son", "dar", "der", "den", "ton"};
Random generator = new Random();
int i=0;
while (i < arraySize) {
String valueString;
valueString = firstSylStringArray [generator.nextInt( firstSylStringArray.length) ];
valueString += secondSylStringArray[generator.nextInt(secondSylStringArray.length) ];
valueString += thirdSylStringArray [generator.nextInt( thirdSylStringArray.length) ];
if (!checkTable.contains(valueString)) {
// Have not seen pseudo word string before, so add it to the list array list
uniqueWordStringArray[i] = valueString;
checkTable.add(valueString,valueString);
i++;
}//end if
}//while
return uniqueWordStringArray;
}
/* Insert all of the values in the array into the hash table.
* #param dict The dictionary to insert all the words into.
*/
private static void insertAllData(DictionaryInterface<String,String> dict, String[] dataArray) {
for (String wordString : dataArray) {
dict.add(wordString, wordString);
}
}//insertAllData()
}//HashPerformanceClass

How to search multi keywork in linq query

i have this code in homepage
CheckBox[] ch= new CheckBox[12];
ch[0] = ChkContextA;
ch[1]= ChkContextB;
ch[2]= ChkContextC;
ch[3]= ChkContextD;
ch[4]= ChkContextE;
ch[5]= ChkContextF;
ch[6]= ChkContextG;
ch[7]= ChkContextH;
ch[8]= ChkContextI;
ch[9]= ChkContextJ;
ch[10]= ChkContextK;
ch[11]= ChiContextL;
for (int i = 0; i < 11; i++)
if (ch[i].Checked) search += ch[i].Text + " ";
Response.Redirect("SearchEstate.aspx?content="+search);
and this code in SearchEstate
var content = Request.QueryString["content"];
RealEstateEntities db = new RealEstateEntities();
var query = from O in db.Owners
join E in db.Estates on O.OwnerID equals E.OwnerID
join P in db.Properties on E.PropertyID equals P.PropertyID
where P.Facilities.Contains(content)
select new
{
regdate = E.RegisterDate,
region = E.Region,
Estype = E.EstateType,
Fac = P.Facilities,
deal = P.DealType,
price = P.TotalCost,
img = E.Picture,
addrss = O.Address,
area = P.Area,
tel = P.TellNum,
bed = P.RoomNum,
park = P.ParikingNum
};
Repeater2.DataSource = query.OrderByDescending(x => x.regdate);
Repeater2.DataBind();
when user checked some checkbox "content" for example have this value:
SearchEstate.aspx?content=ContextB ContextE ContextJ
I Want search this values in Facility field in db
How can I do this? (Sorry for my bad English)
I have the feeling your are looking for something along the lines of this query:
var content = Request.QueryString["content"];
string[] contentArray = content.Split(' ');
//...
var query = //...
where P.Facilities.Any(f => contentArray.Contains(f.FacilityName))
//...
(or instead of FacilityName some other property of Facility)
But I am not sure.