I need to create Mysql tables using this XML but i can't find the way to import all the child's data.
This is the XML.
<product>
<ref>2101</ref>
<name>VERSALLES</name>
<printjobs>
<printjob>
<teccode>100115</teccode>
<tecname>TAMPOGRAFÍA E
</tecname>
<areas>
<area>
<areacode>384</areacode>
<areaname>En la tapa</areaname>
</area>
</areas>
</printjob>
<printjob>
<teccode>101200</teccode>
<tecname>TERMOGRABADO SECO
</tecname>
<areas>
<area>
<areacode>488</areacode>
<areaname>Esquina inferior derecha de la portada</areaname>
</area>
</areas>
</printjob>
<printjob>
<teccode>101201</teccode>
<tecname>TERMOGRABADO CINTA COLOR
</tecname>
<areas>
<area>
<areacode>488</areacode>
<areaname>Esquina inferior derecha de la portada</areaname>
</area>
</areas>
</printjob>
</printjobs>
</product>
<product>
<ref>2233</ref>
<name>1L</name>
<printjobs>
<printjob>
<teccode>100115</teccode>
<tecname>TAMPOGRAFÍA E
</tecname>
<areas>
<area>
<areacode>259</areacode>
<areaname>En el cuerpo</areaname>
</area>
</areas>
</printjob>
</printjobs>
</product>
I tried to import using LOAD DATA LOCAL INFILE to create a different table for area, printjob and product but its only imports the first area of every product.
This is the SQL that i used for area.
LOAD DATA LOCAL INFILE '/var/lib/mysql/allprintdatafile_esp.xml'
INTO TABLE areas
CHARACTER SET 'utf8'
LINES STARTING BY '<product>' TERMINATED BY '</product>'
(#product)
SET
id = NULL,
id_area = ExtractValue(#product, '//areacode'),
id_print_job = ExtractValue(#product, '//teccode'),
id_product = ExtractValue(#product, '//ref'),
areaname = ExtractValue(#product, '//areaname'),
);
Once imported I need the table to look like this.
id
id_area
id_print_job
id_product
areaname
1
384
100115
2101
En la tapa
2
488
101200
2101
Esquina inferior derecha de la portada
3
488
101201
2101
En la tapa
4
259
100115
2233
En el cuerpo
Thank you.
I took over an old project under Symfony 4, which I would like to improve.
I have pages that use pagination, with a service that I created that takes parameters like class, maximum number of elements per page, and so on.
On one of my pages, I added a search field to filter by name the display of a list.
To give you an idea of the function that returns the data:
/**
* Permet de récupérer les données paginées pour une entité spécifique
*
* Elle se sert de Doctrine afin de récupérer le repository pour l'entité spécifiée
* puis grâce au repository et à sa fonction findBy() on récupère les données dans une
* certaine limite et en partant d'un offset
*
* #throws Exception si la propriété $entityClass n'est pas définie
*
* #return array
*/
public function getData()
{
if (empty($this->entityClass)) {
throw new \Exception("Vous n'avez pas spécifié l'entité sur laquelle nous devons paginer ! Utilisez la méthode setEntityClass() de votre objet PaginationService !");
}
// 1) Calculer l'offset
$offset = $this->currentPage * $this->limit - $this->limit;
// 2) Demander au repository de trouver les éléments à partir d'un offset et
// dans la limite d'éléments imposée (voir propriété $limit)
return $this->manager
->getRepository($this->entityClass)
->findBy([], [], $this->limit, $offset);
}
So now my goal is to ensure that the function can handle the case when I asked him to sort in the results due to a request DQL example.
On one of my pages, thanks to the search filter, I have to enter the first name or the name of a user (or some characters are enough).
This translates to the following DQL query:
public function getUsersByName($name)
{
return $this->createQueryBuilder('u')
->where('u.nom LIKE :name OR u.prenom LIKE :name')
->setParameter('name', $name . '%')
->orderBy('u.nom', 'ASC')
->getQuery()
->getResult();
}
How could I integrate this into my function? The goal being to do that for any query eventually. I just need to add the limit and the offset to the result
EDIT:
Is is possible to make something like :
$function = getUsersByName;
$parameters = $this->name;
return $this->manager
->getRepository($this->entityClass)
->$function($parameters);
If I'm not wrong, you just need to replace :
return $this->manager
->getRepository($this->entityClass)
->findBy([], [], $this->limit, $offset);
by :
return $this->manager
->getRepository($this->entityClass)
->getUsersByName($name, $this->limit, $offset);
Assuming you changed the method in your Repo for :
public function getUsersByName($name, $limit = null, $offset = 0)
{
$query = $this->createQueryBuilder('u')
->where('u.nom LIKE :name OR u.prenom LIKE :name')
->setParameter('name', $name . '%')
->orderBy('u.nom', 'ASC');
if($limit){
$query->setFirstResult($offset)
->setMaxResults($limit);
}
return $query->getQuery()
->getResult();
}
Did I understand your problem well ?
I'm using the code described in the GAS documentation to retrieve my Twitter timeline.
The lines
var response = twitterService.fetch('https://api.twitter.com/1.1/statuses/home_timeline.json?count=1');
response=response.getContentText();
yield the following result:
[{"created_at":"Sun Jan 14 15:30:00 +0000 2018","id":952563458616172544,"id_str":"952563458616172544","text":"#UltimOra, \u201cAi piedi le Clarks\u201d; #LiberieUguali trova il primo punto di convergenza fra i vari leader https:\/\/omissis","truncated":false,"entities":{"hashtags":[{"text":"UltimOra","indices":[0,9]},{"text":"LiberieUguali","indices":[33,47]}],"symbols":[],"user_mentions":[],"urls":[{"url":"https:\/\/omissis","expanded_url":"http:\/\/www.lercio.it\/ai-piedi-le-clarks-liberi-e-uguali-trova-il-primo-punto-di-convergenza-fra-i-vari-leader\/","display_url":"lercio.it\/ai-piedi-le-cl\u2026","indices":[102,125]}]},"source":"\u003ca href=\"https:\/\/about.twitter.com\/products\/tweetdeck\" rel=\"nofollow\"\u003eTweetDeck\u003c\/a\u003e","in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":910827588,"id_str":"910827588","name":"lercio-notizie","screen_name":"lercionotizie","location":"","description":"Dal 13 aprile 2017 in fumetteria e libreria con \"Lercio, lo sporco che fa notizia. Il libro\" (Shockdom)","url":"http:\/\/omissis","entities":{"url":{"urls":[{"url":"http:\/\/omissis","expanded_url":"http:\/\/www.lercio.it","display_url":"lercio.it","indices":[0,22]}]},"description":{"urls":[]}},"protected":false,"followers_count":491614,"friends_count":25,"listed_count":712,"created_at":"Sun Oct 28 18:19:33 +0000 2012","favourites_count":385,"utc_offset":3600,"time_zone":"Amsterdam","geo_enabled":false,"verified":false,"statuses_count":7335,"lang":"it","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"FFFFFF","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/696203701\/001bc779080491195bc16054af629016.png","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/696203701\/001bc779080491195bc16054af629016.png","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/2932719853\/4bcd23b39293870bf1832aec72b6fe3d_normal.png","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/2932719853\/4bcd23b39293870bf1832aec72b6fe3d_normal.png","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/910827588\/1467828171","profile_link_color":"9B1212","profile_sidebar_border_color":"000000","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":true,"follow_request_sent":false,"notifications":false,"translator_type":"none"},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":73,"favorite_count":186,"favorited":false,"retweeted":false,"possibly_sensitive":false,"possibly_sensitive_appealable":false,"lang":"it"}]
But when I add the code line
response=JSON.parse(response);
the JSON file is totally altered, it doesn't even look a JSON file and its content becomes:
{possibly_sensitive_appealable=false, in_reply_to_status_id_str=null, in_reply_to_status_id=null, created_at=Sun Jan 14 15:30:00 +0000 2018, in_reply_to_user_id_str=null, source=TweetDeck, retweet_count=73, retweeted=false, geo=null, in_reply_to_screen_name=null, is_quote_status=false, id_str=952563458616172544, in_reply_to_user_id=null, favorite_count=186, id=9.5256345861617254E17, text=#UltimOra, “Ai piedi le Clarks”; #LiberieUguali trova il primo punto di convergenza fra i vari leader https://omissis, place=null, lang=it, favorited=false, possibly_sensitive=false, coordinates=null, truncated=false, entities={urls=[Ljava.lang.Object;#7d41de2d, hashtags=[Ljava.lang.Object;#5e05507d, user_mentions=[Ljava.lang.Object;#7b5572f2, symbols=[Ljava.lang.Object;#fb373c9}, contributors=null, user={utc_offset=3600, friends_count=25, profile_image_url_https=https://pbs.twimg.com/profile_images/2932719853/4bcd23b39293870bf1832aec72b6fe3d_normal.png, listed_count=712, profile_background_image_url=http://pbs.twimg.com/profile_background_images/696203701/001bc779080491195bc16054af629016.png, default_profile_image=false, favourites_count=385, description=Dal 13 aprile 2017 in fumetteria e libreria con "Lercio, lo sporco che fa notizia. Il libro" (Shockdom), created_at=Sun Oct 28 18:19:33 +0000 2012, is_translator=false, profile_background_image_url_https=https://pbs.twimg.com/profile_background_images/696203701/001bc779080491195bc16054af629016.png, protected=false, screen_name=lercionotizie, id_str=910827588, profile_link_color=9B1212, is_translation_enabled=false, translator_type=none, id=910827588, geo_enabled=false, profile_background_color=FFFFFF, lang=it, has_extended_profile=false, profile_sidebar_border_color=000000, profile_text_color=333333, verified=false, profile_image_url=http://pbs.twimg.com/profile_images/2932719853/4bcd23b39293870bf1832aec72b6fe3d_normal.png, time_zone=Amsterdam, url=http://omissis, contributors_enabled=false, profile_background_tile=false, profile_banner_url=https://pbs.twimg.com/profile_banners/910827588/1467828171, entities={description={urls=[Ljava.lang.Object;#7c7074a4}, url={urls=[Ljava.lang.Object;#80245ef}}, statuses_count=7335, follow_request_sent=false, followers_count=491614, profile_use_background_image=true, default_profile=false, following=true, name=lercio-notizie, location=, profile_sidebar_fill_color=DDEEF6, notifications=false}}
What's wrong?
You are probably using Logger.log for checking results of code execution.
As noted in documentation:
The method Logger.log expects a string value, but if you pass in an object or array it will do its best to convert that into a string.
So response in this case response=response.getContentText() will give you String with expected behaviour when used in Logger.log, but in case response=JSON.parse(response) will give Object, that will have output in Logger.log in format [key1=val1, key2=val2, ..].
You can get used to it, or you can use convertion of your object to string before logging it:
Logger.log(JSON.stringify(response))
I'm automating with robot framework but I'm getting this error
No keyword with name 'Fetch From Left' found.
I don't understand the cause, I'm new in this tool
Here is my code:
${FILE_RUTS_INFORMACION_PERSONAL} archivo2.csv
Im reading CSV file with three DNI
Carga RUTs
[Documentation] Carga lista de RUTs a validar desde archivo csv
[Arguments] ${file_name}
${data}= read csv file ${file_name}
[return] ${data}
Here is the error:
Consultar WS
[Documentation] Lee RUTs de archivo csv y consulta cada uno al Experto Original y Migrado.
[Arguments] ${data}
${rutsd}= Set Variable 0
${dv} = Set Variable 0
Log To Console .
:FOR ${element} IN ${data}
\ ${rutsd}= Fetch From Left #{element}[0] ;
\ ${dvymas}= Get Substring #{element}[0] -1
\ ${dv}= Fetch From Left ${dvymas} ;
\ Log To Console Consultando RUT ${rutsd}...
\ Run Keyword And Continue On Failure WS Experto Orignal ${rutsd} ${dv}
ERROR:
FOR ${element} IN [ ${data} ]
Start / End / Elapsed: 20170823 10:00:11.149 / 20170823 10:00:11.151 / 00:00:00.002
00:00:00.002VAR ${element} = [['169233xxx;'], ['169129xxx;'], ['189925xxx;']]
Start / End / Elapsed: 20170823 10:00:11.149 / 20170823 10:00:11.151 / 00:00:00.002
00:00:00.000KEYWORD ${rutsd}= = Fetch From Left #{element}[0], ;
Start / End / Elapsed: 20170823 10:00:11.151 / 20170823 10:00:11.151 / 00:00:00.000
10:00:11.151 FAIL No keyword with name 'Fetch From Left' found.
You need to import the String library. See the user guide for more information. Only the BuiltIn library doesn't need to be imported. Looking at the code you posted, you don't seem to be importing it.
Adding this to your settings section should do the trick
*** Settings ***
Library String