Semantic Wiki: Check form input if value already exists - mediawiki

we have a formular to create host names with some additional information.
Inside the formular we include a template, which gets the values via input fields:
{{{for template|IP|multiple|add button text=Add IP}}}
'''IP:''' {{{field|IP|mandatory|property=Host IP}}}
'''MAC:''' {{{field|MAC}}}
{{{end template}}}
We want to have a check if the given IP adress is already used by another host.
I already tried creating an array and iterating through the values and compare it with a given value: this works.
{{#arraydefine: myArray1 | {{ #ask: [[IP::+]] | mainlabel=- |headers=hide | ?IP }} }}
{{#arrayprint: myArray1||####| {{#ifeq: #### | {{{IP}}} | Duplicate #### <br>| No duplicate #### <br>}} }}
However, if I include this in the form itself, the IP input box doesn't assign the value to an actual variable {{{IP}}} - therefor I cannot access it with the method above.
I then tried to use it on the template "IP" directly. That works, but now it checks with every existing site which uses this template and of course, finds duplicates (because it checks it's own value against the array which also contains the value since it's already existing).
I spent almost 2 work days on this little issue now and I reach the limits of my understanding of semantic wiki. Any ideas would be appreciated.
Thank you in advance!

Since your page name is the host name, and host pages store the IP, you can do the following:
Ask for pages with the same IP as the current page :
{{#ask:[[IP::{{{IP}}}]] |mainlabel=-|?#-=}}
Store the result into an array, lets call it "hosts". The array now contains host names that have the same IP as the current page (with html link removed) and the current page itself.
Create a new array containing a single value, the current page name (using {{FULLPAGENAME}} magic word), lets call it "current"
Substract the two arrays :
{{#arraydiff:duplicate|hosts|current}}
Then check the length of the resulting array "duplicate".
if arraysize > 0, a host page different from current page exists with the same IP.

Related

SPFX Pages - Using html Handlebars template - Issue with lookup column

I am quite new in the usage of SPFX but I have created a page using Content Query with HTML template of Handlebars and I have an issue for getting the information from column type lookup.
I have a list "Document" with :
Column "Owner" defined as Lookup people in a group sharepoint users
Column "Proces" defined as lookup on a list containing the different process information
In my HTML template I used Owner.rawValue and Proces.rawValue and got the id (Example: Owner: 25 and process = 36).
Does someone know, have the corresponding code to be able to get :
For Owner, the username (can be a string to be manipulated, no issue)
For Proces, the title being the column used in loopk field
Many thanks and at your disposal for further instruction if not clear

I am trying to seperate the numbers to odd and even and then pass to to the url path using variable in jmeter

I have a get request from where I am taking all the id values , using json extractor I have extracted and named it id and used match number as -1
Now I want to pass this id variable into a post url paths
And this post requests are set inside a for each controller to run for required no of iterations
I have given for each controller values as
Input variable : id
Start index : 0
End index : ${id_matchNr}
Output var name : outid
Paths arelike
Post Path 1: https://demo.qwe.com/blue${outid}
Post Path 2:
https://demo.qwe.com/blue${outid}
I want to pass only even id numbers to path 1 and odd id numbers to path two
So I have used if controller and gave expression as
${outid}%2==0 to first path
And ${outid}%2!=0 to other if controller and placed the path 2 request
And checked the interpret condition
These two rqsts are in for each controller.
When I run the script I am getting a blank output for the post rqsts.
Can you please help me out
The function or variable you put in the If Controller must evaluate to true, only this way the If Controller will run its children. In your case you're providing just a string.
You need to wrap it into i.e. __jexl3() function like:
${__jexl3(${outid}%2==0,)}
this way it should work as expected.
More information: 6 Tips for JMeter If Controller Usage

ColdFusion convert hidden form variables to a structure

The app I am working on has hidden input variables set on initial load of the page. The variables need to be accessed across all pages. The reason for not converting these to session variables is the user can open another browser with different parameters and passing those value as hidden inputs make it work without any issue. What is the best possible alternative so as to get rid of these hidden inputs..I tried converting all variables into a Structure, but again the structure needs to be posted as part of form submission to make it available to subsequent pages.Another disadvantage of this app is use of frames.I don't have any code to post.
It sounds as if you want different browsers instances which are associated with the same web session to maintain their own distinct sets of data. Doing this by passing form or url variables around seems like a bad idea.
One approach that you could use would be, onSessionStart (or as required), create a structure in the users session to hold instances of the data. For example
session.data = {
someRandomKey: {
valueA: 42,
valueB: "Porridge"
}
}
Then just pass someRandomKey as a hidden form field or querystring parameter. Now, when they submit the form to update variables you use the id from the hidden form field to find the appropriate structure from session.data.
When the user needs a new instance of this form, give them some way, like a link or button, that creates a new unique key, inserts a struct in session.data with this key and populates it with whatever defaults are needed then loads the form passing along the new id as a hidden form field or querystring param again.

Passing properties in Semantic MediaWiki

Currently I have 3 categories, Application, Application Instance and Vendor.
Right now Application has a link (via property Made By) to Vendor. Application instances need to link back to Vendor via a property. I have the query I can use to return the application name and vendor is
{{#ask:
[[Category:Program]][[{{{Program}}}]]
|?Made By
}}
however
{{#set:Made By={{#ask:
[[Category:Program]][[{{{Program}}}]]
|?Made By
}}}}
doesn't work to set the property to the value of vendor which is returned by the ask query.
Are there other ways to do this?
Maybe a bit late but you could probably do this using a template to set the property. Something like this?
In the Application Instance template (or manually on each Application Instance page) add the following ask query:
{{#ask:[[Category:Program]][[{{{Program}}}]]
|?Made By
|link=none
|format=template
|template=Set made by
}}
Then create the template "wiki/Template:Set made by" with the following:
includeonly>
{{#set:
Made By={{{2}}}
}}
</includeonly>
Notes
Parameter {{{1}}} is the subject which is the page name and {{{2}}} will be the result for 'Made By'.
Stripping the link from the query results prevents the extra text being passed to the set command which would confuse things.
You can also use the inverse of properties in queries by adding a minus sign in front of them. (e.g. '-Made By')

Laravel Eloquent is not saving properties to database ( possibly mysql )

I'm having a strange issue.
I created a model observer for my user model. The model observer is being run at 'saving'. when I dump the object at the very end of the user model to be displayed ( this is just before it saves.. according to laravel docs ) it displays all the attributes set correctly for the object, I've even seen an error that showed the correct attributes as set and being inserted into my database table. However, after the save has been completed and I query the database, two of the fields are not saved into the table.
There is no code written by myself sitting between the point where I dumped the attributes to check that they had been set and the save operation to the database. so I have no idea what could be causing this to happen. All the names are set correctly, and like I said, the attributes show as being inserted into the database, they just never end up being saved, I receive no error messages and only two out of ten attributes aren't being saved.
In my searches I have found many posts detailing that the $fillable property should be set, or issues relating to a problem with variables being misnamed or unset, however because I already have the specific attributes not being saved specified in the $fillable array, on top of the fact that they print out exactly as expected pre save, I don't believe those issues are related to the problem I am experiencing.
to save I'm calling:
User::create(Input::all());
and then the observer that handles the data looks like this:
class UserObserver {
# a common key between the city and state tables, helps to identify correct city
$statefp = State::where('id',$user->state_id)->pluck('statefp');
# trailing zeros is a function that takes the first parameter and adds zeros to make sure
# that in this case for example, the dates will be two characters with a trailing zero,
# based on the number specified in the second parameter
$user->birth_date = $user->year.'-'.$user->trailingZeros( $user->month, 2 ).'-'.$user->trailingZeros( $user->day, 2 );
if(empty($user->city)){
$user->city_id = $user->defaultCity;
}
$user->city_id = City::where( 'statefp', $statefp )->where('name', ucfirst($user->city_id))->pluck('id');
# if the user input zip code is different then suggested zip code then find location data
# on the input zip code input by the user from the geocodes table
if( $user->zip !== $user->defaultZip ){
$latlon = Geocode::where('zip', $user->zip)->first();
$user->latitude = $latlon['latitude'];
$user->longitude = $latlon['longitude'];
}
unset($user->day);
unset($user->month);
unset($user->year);
unset($user->defaultZip);
unset($user->defaultCity);
}
that is the code for the two values that aren't being set, when I run
dd($user);
all the variables are set correctly, and show up in the mysql insert attempt screen with correct values, but they do not persist past that point.. it seems to me that possibly mysql is rejecting the values for the city_id and the birth_date. However, I cannot understand why, or whether it is a problem with Laravel or mysql.
since I was calling
User::create();
I figured I'd try to have my observer listen to:
creating();
I'm not sure why it only effected the date and city variables, but changing the function to listen at creating() instead of saving() seems to have solved my problem.