text:
package org.elasticsearch.action.count;

import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.support.broadcast.BroadcastRequest;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;

import java.io.IOException;
import java.util.Arrays;

/**
 * A request to count the number of documents matching a specific query. Best created with
 * {@link org.elasticsearch.client.Requests#countRequest(String...)}.
 *
 * @see CountResponse
 * @see org.elasticsearch.client.Client#count(CountRequest)
 * @see org.elasticsearch.client.Requests#countRequest(String...)
 */
public class CountRequest extends BroadcastRequest<CountRequest> {

    @Nullable
    protected String routing;

    @Nullable
    private String preference;

    private String[] types = Strings.EMPTY_ARRAY;

    private final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();

    /**
     * Constructs a new count request against the provided indices. No indices provided means it will
     * run against all indices.
     */
    public CountRequest(String... indices) {
        super(indices);
        searchSourceBuilder.size(0);
    }

    /**
     * The minimum score of the documents to include in the count.
     */
    public Float minScore() {
        return searchSourceBuilder.minScore();
    }

    /**
     * The minimum score of the documents to include in the count. Defaults to <tt>-1</tt> which means all
     * documents will be included in the count.
     */
    public CountRequest minScore(float minScore) {
        this.searchSourceBuilder.minScore(minScore);
        return this;
    }

    /**
     * The query to execute
     */
    public CountRequest query(QueryBuilder<?> queryBuilder) {
        this.searchSourceBuilder.query(queryBuilder);
        return this;
    }

    /**
     * The types of documents the query will run against. Defaults to all types.
     */
    public String[] types() {
        return this.types;
    }

    /**
     * The types of documents the query will run against. Defaults to all types.
     */
    public CountRequest types(String... types) {
        this.types = types;
        return this;
    }

    /**
     * A comma separated list of routing values to control the shards the search will be executed on.
     */
    public String routing() {
        return this.routing;
    }

    /**
     * A comma separated list of routing values to control the shards the search will be executed on.
     */
    public CountRequest routing(String routing) {
        this.routing = routing;
        return this;
    }

    /**
     * The routing values to control the shards that the search will be executed on.
     */
    public CountRequest routing(String... routings) {
        this.routing = Strings.arrayToCommaDelimitedString(routings);
        return this;
    }

    public CountRequest preference(String preference) {
        this.preference = preference;
        return this;
    }

    public String preference() {
        return this.preference;
    }

    /**
     * Upon reaching terminateAfter counts, the count request will early terminate
     */
    public CountRequest terminateAfter(int terminateAfterCount) {
        this.searchSourceBuilder.terminateAfter(terminateAfterCount);
        return this;
    }

    public int terminateAfter() {
        return this.searchSourceBuilder.terminateAfter();
    }

    @Override
    public void readFrom(StreamInput in) throws IOException {
        throw new UnsupportedOperationException("CountRequest doesn't support being sent over the wire, just a shortcut to the search api");
    }

    @Override
    public void writeTo(StreamOutput out) throws IOException {
        throw new UnsupportedOperationException("CountRequest doesn't support being sent over the wire, just a shortcut to the search api");
    }

    @Override
    public String toString() {
        return "count request indices:" + Arrays.toString(indices) +
                ", types:" + Arrays.toString(types) +
                ", routing: " + routing +
                ", preference: " + preference +
                ", source:" + searchSourceBuilder.toString();
    }

    public SearchRequest toSearchRequest() {
        SearchRequest searchRequest = new SearchRequest(indices());
        searchRequest.source(searchSourceBuilder);
        searchRequest.indicesOptions(indicesOptions());
        searchRequest.types(types());
        searchRequest.routing(routing());
        searchRequest.preference(preference());
        return searchRequest;
    }
}


text:
<?php
include_once('../pdquser/PHPMailer/class.phpmailer.php');
include_once('../pdquser/MPDF60/mpdf.php');
require_once('../pdquser/services/NcrbasicinfoService.php');
require_once('../pdquser/services/PdqinfoService.php');
require_once('../pdquser/services/PdqimmediateactionService.php');
require_once('../pdquser/services/ReportsService.php');

$method = $_SERVER['REQUEST_METHOD'];
$request = explode("/", substr(@$_SERVER['PATH_INFO'], 1));

if( $method == 'GET' && $request[0] == 'test') {
	$sv = new MailService();
    $sv->test();
}

class MailService {

	public $mail;
	public $email;
	public $pass;

	public function __construct()
	{

		$this->mail = new PHPMailer();
		$this->email = 'report@vause.co.th';
		$this->pass = '11111111';
	}

public function sendMailPDQ($emailTo,$emailName,$ccTo,$ccName,$pdqID){

       $Immediate = new PdqimmediateactionService();
       $pdqInfo = new PdqinfoService();

       $getImme = $Immediate->getPdq_immediateactionByPDQID($pdqID);
       $getInfo = $pdqInfo->getAllPdq_basicinfoAdvancedBypdqID($pdqID);

       if($getInfo->basic_2==='1'){
            $nearmiss = 'Yes';
       }else{
            $nearmiss = 'No';
       }

        if($getInfo->basic_6==='1'){
            $ncr = 'Yes';
       }else{
            $ncr = 'No';
       }

		$this->mail->CharSet = "utf-8";
		$this->mail->IsSMTP();
		$this->mail->SMTPDebug = 0;
		$this->mail->SMTPAuth = true;
		$this->mail->SMTPSecure = "tls";
		$this->mail->Host = "smtp.gmail.com"; // SMTP server
		$this->mail->Port = 587;
		$this->mail->Username = $this->email; // account SMTP
		$this->mail->Password = $this->pass; //  account SMTP
		//From:
		$this->mail->SetFrom($this->email, "PDQ Report");
		//TO:
       $this->mail->AddAddress($emailTo, $emailName);
       $this->mail->AddCC("hseq.thailand@vause.co.th", "HSEQ");
       $this->mail->AddCC($ccTo, $ccName);
       /** Test by*/
		//$this->mail->AddAddress("patcharin@infomediacomm.com", "Patcharin");

		//ReplayTo:
		$this->mail->AddReplyTo($this->email, " ");
		//Subject:
		if(!empty($subject)){
		 	$sub = $subject;
		}  else  {
			$sub = 'PDQ Reported by '.$ccName;
		}
		$this->mail->Subject = $sub;
		//Attachment:
		// $attach_file = "./".$strFileName;
		// $this->mail->AddAttachment($attach_file);
		//Display HTML Y/N
		$this->mail->IsHTML(true);

		if(!empty($msg)){
			$message = $msg;
		} else {

            $message1  = 'Dear '.$getInfo->super_name.'
';
            $message2  = '

REPORTED BY	            :	    '.$getInfo->Ename.'

EDITTED BY	            :	    '.$ccName.'

PDQ ID	            :	    '.$pdqID.'

CATEGORY	            :	    '.$getInfo->basic_category.'

EVENT DATE	            :	    '.$getInfo->basic_eventDate.'

CUSTOMER	            :	    '.$getInfo->client.'

LOCATION	            :	    '.$getInfo->location.'

WHERE	            :	    '.$getInfo->applied.'

';
            $message3  = '

NEAR MISS	            :	    '.$nearmiss.'

NON CONFORMANCE	            :	    '.$ncr.'

';
            $message4 = '

OBSERVATION	            :	    '.$getInfo->basic_description.'

';
             $message5 = '

ACTION ITEM	            :

';

            $message6 ='

                    No.
                    Responsible
                    Details
                    Expected Closing
                    Status

';
            foreach ($getImme as $value) {
            $message6 .='

            		'.$value->imeItem.'
            		'.$value->ime_responsible.'
                    '.$value->ime_actionItem.'
                    '.$value->ime_expected.'
                    '.$value->ime_status.'

';
            }
            $message6 .='
';

            $message7 = '

VISIT PDQ REPORT LINK	            :	   Click Here

';

             $message8 = '

Best Regards,
'.$ccName.'
'.$getInfo->emp_jobfunction;
            //	$message = 'You Have A New PDQ Report From '.$ccName.'
PDQ ID : '.$pdqID.'
Observation : '.$getInfo->basic_description.'
Please Check -> http://vause.dyndns-server.com:8888/online_report/pdquser/index.html
';
		}
		//Body Message:
		$this->mail->Body = $message1.$message2.$message3.$message4.$message5.$message6.$message7.$message8;
		//Sent.....
		if(!$this->mail->Send())
		{
			return 'Error';
		}
		else
		{
			return 'Message has been sent';
		}

	}

public function sendMailPDQAttachment($emailTo,$emailName,$ccTo,$ccName,$pdqID){
       //mpdf//
        $ncrInfo = new NcrbasicinfoService();
        $pdqInfo = new PdqinfoService();
        $Immediate = new PdqimmediateactionService();
        $empAdress = new ReportsService();

        $getInfoNcr = $ncrInfo->getNcr_basicinfoByID($pdqID);
        $getInfo = $pdqInfo->getAllPdq_basicinfoAdvancedBypdqID($pdqID);
        $getImme = $Immediate->getPdq_immediateactionByPDQID($pdqID);
        $getAddress = $empAdress->getAddress($getInfo->empID);

        $check = '../pdquser/upload_images/checkbox_yes.png';
        $uncheck = '../pdquser/upload_images/checkbox_no.png';
        $logoVause = '../pdquser/upload_images/logo-pdf.jpg';
        $imgDefault = '../pdquser/upload_images/default.png';

        if($getInfo->basic_image1===NULL){
            $imgsrc1 = $imgDefault;
             $evident1 = ' ';
        }else{
            $imgsrc1 = '../pdquser/upload_images/'.$getInfo->basic_image1;
            $evident1 = 'Evident1';
        }
        if($getInfo->basic_image2===NULL){
            $imgsrc2 = $imgDefault;
             $evident2 = ' ';
        }else{
            $imgsrc2 = '../pdquser/upload_images/'.$getInfo->basic_image2;
            $evident2 = 'Evident2';
        }
        if($getInfo->basic_4===NULL){
            $imgsrc3 = $imgDefault;
            $evident3 = ' ';
        }else{
            $imgsrc3 = '../pdquser/upload_images/'.$getInfo->basic_4;
            $evident3 = 'Evident3';
        }
        if($getInfo->basic_5===NULL){
            $imgsrc4 = $imgDefault;
            $evident4 = ' ';
        }else{
            $imgsrc4 = '../pdquser/upload_images/'.$getInfo->basic_5;
            $evident4 = 'Evident4';
        }

        if($getInfo->basic_2==='1'){
            $nearmissYes = $check;
            $nearmissNo  = $uncheck;
        }else{
            $nearmissYes = $uncheck;
            $nearmissNo = $check;
        }

        if($getInfo->basic_6==='1'){
            $ncrYes = $check;
            $ncrNo  = $uncheck;
        }else{
            $ncrYes = $uncheck;
            $ncrNo  = $check;
        }

         if($getInfo->basic_2==='1'){
            $nearmiss = 'Yes';
       }else{
            $nearmiss = 'No';
       }

        if($getInfo->basic_6==='1'){
            $ncr = 'Yes';
       }else{
            $ncr = 'No';
       }

            $mpdf = new mPDF('c','A3','','',15,15,30,25,10,10);
            $mpdf->SetHTMLHeader('

'.$getAddress->companyname.'

PDQ / IMMEDIATE ACTION ITEM REPORT

            		');

            /** VAUSE WIRELINE SERVICES LTD. */
            $aradd = preg_split("/[.]/", $getAddress->address,2,PREG_SPLIT_DELIM_CAPTURE);
            $mpdf->SetHTMLFooter('

            ');

            $htmlinfo ='

            		';
            $htmlinfo .= '

Customer	            :	    '.$getInfo->client.'

Where	                 :	    '.$getInfo->applied.'

PDQ No	               :	    '.$getInfo->pdqID.'

Location	            :	    '.$getInfo->location.'

Business Unit	           :	    '.$getInfo->business.'

Category	             :	   '.$getInfo->basic_category.'

Reported By	   :	    '.$getInfo->Ename.'

Job Function	  :	    '.$getInfo->emp_jobfunction.'

NCR	 :
                                	Yes
                                	No

Status	   :	    '.$getInfo->basic_status.' - (Progress '.$getInfo->basic_1.' %)

Supervisor	   :	    '.$getInfo->super_name.'

Near Miss	  :
                             	Yes
                             	No

';

            $htmldesc ='

                         	  OBSERVATION

';
            $htmldesc .='

  '.$getInfo->basic_description.'

';

            if($getInfo->basic_image1 !== NULL){
            $htmlevident ='

                         	  EVIDENT

';
            }
            $htmlevident .='

                        '.$getInfo->basic_7.'
                        '.$getInfo->basic_8.'
                        '.$getInfo->basic_9.'
                        '.$getInfo->basic_10.'

';
            $htmlevident .='

';

            $htmlimme ='

                                               IMMEDIATE ACTION ITEM
                                             Status : '.$getInfo->basic_status.' (Progress '.$getInfo->basic_1.' %)

';

            $htmlimme .='

                    No.
                    Responsible
                    Details
                    Expected Closing
                    Status

';
            foreach ($getImme as $value) {
            $htmlimme .='

            		'.$value->imeItem.'
            		'.$value->ime_responsible.'
                    '.$value->ime_actionItem.'
                    '.$value->ime_expected.'
                    '.$value->ime_status.'

';
            }
            $htmlimme .='
';

            $getInfo->sub_ina    =   $getInfo->sub_ina==='Y'? $check:$uncheck;
            $getInfo->sub_human  =   $getInfo->sub_human==='Y'? $check:$uncheck;
            $getInfo->sub_manual =   $getInfo->sub_manual==='Y'? $check:$uncheck;
            $getInfo->sub_safety =   $getInfo->sub_safety==='Y'? $check:$uncheck;
            $getInfo->sub_percep =   $getInfo->sub_percep==='Y'? $check:$uncheck;
            $getInfo->sub_driving=   $getInfo->sub_driving==='Y'? $check:$uncheck;
            $getInfo->sub_other1     =   $getInfo->sub_other1==='Y'? $check:$uncheck;
            $getInfo->sub_positive   =   $getInfo->sub_positive==='Y'? $check:$uncheck;

            $htmlimme  .='

SUBSTANDARD PRACTICES

sub_ina.'"/>  Inadequate PPE

sub_human.'"/>  Human Behaviour

sub_manual.'"/>  Manual Handling

sub_safety.'"/>  Ignorant of Safety Rules

sub_percep.'"/>  Perception of Risk/Hazards

sub_driving.'"/>  Driving Violations

sub_other1.'"/>  Other '.$getInfo->sub_ment1.'

sub_positive.'"/>  Positive Behavior

';

            $getInfo->sub_tool=$getInfo->sub_tool==='Y'? $check:$uncheck;
            $getInfo->sub_vehicle=$getInfo->sub_vehicle==='Y'? $check:$uncheck;
            $getInfo->sub_work=$getInfo->sub_work==='Y'? $check:$uncheck;
            $getInfo->sub_house=$getInfo->sub_house==='Y'? $check:$uncheck;
            $getInfo->sub_mainten=$getInfo->sub_mainten==='Y'? $check:$uncheck;
            $getInfo->sub_storage=$getInfo->sub_storage==='Y'? $check:$uncheck;
            $getInfo->sub_other2=$getInfo->sub_other2==='Y'? $check:$uncheck;
            $getInfo->sub_excellent=$getInfo->sub_excellent==='Y'? $check:$uncheck;

            $htmlimme   .='

SUBSTANDARD CONDITION

sub_tool.'"/>  Tool/Equipment

sub_vehicle.'"/>  Vehicle / Transportation

sub_work.'"/>  Work Place Environment

sub_house.'"/>  Housekeeping

sub_mainten.'"/>  Maintenance

sub_storage.'"/>  Storage

sub_other2.'"/>  Other '.$getInfo->sub_ment2.'

sub_excellent.'"/>  Excellent Working Condition

';

            $getInfo->sub_inapro=$getInfo->sub_inapro==='Y'? $check:$uncheck;
            $getInfo->sub_lack=$getInfo->sub_lack==='Y'? $check:$uncheck;
            $getInfo->sub_poor=$getInfo->sub_poor==='Y'? $check:$uncheck;
            $getInfo->sub_inasuper=$getInfo->sub_inasuper==='Y'? $check:$uncheck;
            $getInfo->sub_insuff=$getInfo->sub_insuff==='Y'? $check:$uncheck;
            $getInfo->sub_inajob=$getInfo->sub_inajob==='Y'? $check:$uncheck;
            $getInfo->sub_natu=$getInfo->sub_natu==='Y'? $check:$uncheck;
            $getInfo->sub_other3=$getInfo->sub_other3==='Y'? $check:$uncheck;

            $htmlimme   .='

CAUSES

sub_inapro.'"/>  Inadequate Procedures

sub_lack.'"/>  Lack of Tranining

sub_poor.'"/>  Poor Motivation

sub_inasuper.'"/>  Inadequate Supervision

sub_insuff.'"/>  Insufficient Resources

sub_inajob.'"/>  Inadequate Job Knowledge

sub_natu.'"/>  Natural / Weather

sub_other3.'"/>  Other '.$getInfo->sub_ment3.'

';

            $htmlrisk ='

                                               RISK ASSESSMENT
                                             Supervisor Name : '.$getInfo->super_name.'

';
            $htmlrisk .='

Risk Level	  :	  '.$getInfo->risk_level.'

Preventive Action	  :	  '.$getInfo->super_comment.'

';

            $getInfo->riskass_personal    =   $getInfo->riskass_personal==='Y'? $check:$uncheck;
            $getInfo->riskass_fire  =   $getInfo->riskass_fire==='Y'? $check:$uncheck;
            $getInfo->riskass_fall =   $getInfo->riskass_fall==='Y'? $check:$uncheck;
            $getInfo->riskass_property =   $getInfo->riskass_property==='Y'? $check:$uncheck;
            $getInfo->riskass_radiation =   $getInfo->riskass_radiation==='Y'? $check:$uncheck;
            $getInfo->riskass_traffic =   $getInfo->riskass_traffic==='Y'? $check:$uncheck;
            $getInfo->riskass_gas     =   $getInfo->riskass_gas==='Y'? $check:$uncheck;
            $getInfo->riskass_chemical   =   $getInfo->riskass_chemical==='Y'? $check:$uncheck;
            $getInfo->riskass_collision   =   $getInfo->riskass_collision==='Y'? $check:$uncheck;
            $getInfo->riskass_oil   =   $getInfo->riskass_oil==='Y'? $check:$uncheck;
            $getInfo->riskass_explosion   =   $getInfo->riskass_explosion==='Y'? $check:$uncheck;
            $getInfo->riskass_env   =   $getInfo->riskass_env==='Y'? $check:$uncheck;
            $getInfo->riskass_kick   =   $getInfo->riskass_kick==='Y'? $check:$uncheck;
            $getInfo->riskass_fatality   =   $getInfo->riskass_fatality==='Y'? $check:$uncheck;
            $getInfo->riskass_otherrisk   =   $getInfo->riskass_otherrisk==='Y'? $check:$uncheck;

            $htmlrisk  .='

riskass_personal.'"/>  Personal Injury

riskass_fire.'"/>  Fire

riskass_fall.'"/>  Fall Over Board

riskass_property.'"/>  Property Damage

riskass_radiation.'"/>  Radiation Leak

riskass_traffic.'"/>  Traffic Accident

riskass_gas.'"/>  Gas Leak

riskass_chemical.'"/>  Chemical Spill

riskass_collision.'"/>  Collision

riskass_oil.'"/>  Oil Leak

riskass_explosion.'"/>  Explosion

riskass_env.'"/>  ENV. Damage

riskass_kick.'"/>  Kick / Blow-Out

riskass_fatality.'"/>  Fatality

riskass_otherrisk.'"/>  Other '.$getInfo->riskass_mentsrisk.'

';

        $html = $htmlinfo.$htmldesc.$htmlevident.$htmlimme.$htmlrisk;
        $mpdf->AddPage();
        $mpdf->WriteHTML($html);
        $name = $pdqID.'.pdf';
        $content = $mpdf->Output('', 'S');

		$this->mail->CharSet = "utf-8";
		$this->mail->IsSMTP();
		$this->mail->SMTPDebug = 0;
		$this->mail->SMTPAuth = true;
		$this->mail->SMTPSecure = "tls";
		$this->mail->Host = "smtp.gmail.com"; // SMTP server
		$this->mail->Port = 587;
		$this->mail->Username = $this->email; // account SMTP
		$this->mail->Password = $this->pass; //  account SMTP
		//From:
		$this->mail->SetFrom($this->email, "PDQ Report");
		//TO:
        $this->mail->AddAddress($emailTo, $emailName);
        $this->mail->AddCC("hseq.thailand@vause.co.th", "HSEQ");
        $this->mail->AddCC($ccTo, $ccName);
       /** Test by */
		//$this->mail->AddAddress("patcharin@infomediacomm.com", "Patcharin");

		//ReplayTo:
		$this->mail->AddReplyTo($this->email, " ");
		//Subject:
		if(!empty($subject)){
		 	$sub = $subject;
		}  else  {
			$sub = 'PDQ Reported by '.$ccName;
		}
		$this->mail->Subject = $sub;
		//Attachment:
		// $attach_file = "./".$strFileName;
		// $this->mail->AddAttachment($attach_file);
		//Display HTML Y/N
		$this->mail->IsHTML(true);

		if(!empty($msg)){
			$message = $msg;
		} else {

             $message1  = 'Dear '.$getInfo->super_name.'
';
            $message2  = '

REPORTED BY	            :	    '.$getInfo->Ename.'

EDITTED BY	            :	    '.$ccName.'

PDQ ID	            :	    '.$pdqID.'

CATEGORY	            :	    '.$getInfo->basic_category.'

EVENT DATE	            :	    '.$getInfo->basic_eventDate.'

CUSTOMER	            :	    '.$getInfo->client.'

LOCATION	            :	    '.$getInfo->location.'

WHERE	            :	    '.$getInfo->applied.'

';
            $message3  = '

NEAR MISS	            :	    '.$nearmiss.'

NON CONFORMANCE	            :	    '.$ncr.'

';
            $message4 = '

OBSERVATION	            :	    '.$getInfo->basic_description.'

';
             $message5 = '

ACTION ITEM	            :

';

            $message6 ='

                    No.
                    Responsible
                    Details
                    Expected Closing
                    Status

';
            foreach ($getImme as $value) {
            $message6 .='

            		'.$value->imeItem.'
            		'.$value->ime_responsible.'
                    '.$value->ime_actionItem.'
                    '.$value->ime_expected.'
                    '.$value->ime_status.'

';
            }
            $message6 .='
';

            $message7 = '

VISIT PDQ REPORT LINK	            :	   Click Here

';

             $message8 = '

Best Regards,
'.$ccName.'
'.$getInfo->emp_jobfunction;
            //	$message = 'You Have A New PDQ Report From '.$ccName.'
PDQ ID : '.$pdqID.'
Observation : '.$getInfo->basic_description.'
Please Check -> http://vause.dyndns-server.com:8888/online_report/pdquser/index.html
';
		}
		//Body Message:
		$this->mail->Body = $message1.$message2.$message3.$message4.$message5.$message6.$message7.$message8;
        $encoding = "base64";
        $type = "application/octet-stream";

        $this->mail->AddStringAttachment($content,$name);
        //$mpdf->Output($name,'D');
		//Sent.....
		if(!$this->mail->Send())
		{
			return 'Error';
		}
		else
		{
			return 'Message has been sent';
		}

	}

public function sendMailNCR($emailTo,$emailName,$ccTo,$ccName,$pdqID){

        $ncrInfo = new NcrbasicinfoService();
        $pdqInfo = new PdqinfoService();
        $Immediate = new PdqimmediateactionService();
        $empAdress = new ReportsService();

        $getInfoNcr = $ncrInfo->getNcr_basicinfoByID($pdqID);
        $getInfo = $pdqInfo->getAllPdq_basicinfoAdvancedBypdqID($pdqID);
        $getImme = $Immediate->getPdq_immediateactionByPDQID($pdqID);
        $getAddress = $empAdress->getAddress($getInfo->empID);

        // if($getInfoNcr->ncr_cusComplaint==='1'){
//            $complaint = 'Yes';
//        }else{
//            $complaint = 'No';
//        }

		$this->mail->CharSet = "utf-8";
		$this->mail->IsSMTP();
		$this->mail->SMTPDebug = 0;
		$this->mail->SMTPAuth = true;
		$this->mail->SMTPSecure = "tls";
		$this->mail->Host = "smtp.gmail.com"; // SMTP server
		$this->mail->Port = 587;
		$this->mail->Username = $this->email; // account SMTP
		$this->mail->Password = $this->pass; //  account SMTP
		//From:
		$this->mail->SetFrom($this->email, "NCR Report");
		//TO:
        $this->mail->AddAddress($emailTo, $emailName);
        $this->mail->AddCC("hseq.thailand@vause.co.th", "HSEQ");
        $this->mail->AddCC($ccTo, $ccName);
        /** Test by*/
		//$this->mail->AddAddress("patcharin@infomediacomm.com", "Patcharin");

		//ReplayTo:
		$this->mail->AddReplyTo($this->email, " ");
		//Subject:
		if(!empty($subject)){
		 	$sub = $subject;
		}  else  {
			$sub = 'by '.$ccName;
		}
		$this->mail->Subject = $sub;
		//Attachment:
		// $attach_file = "./".$strFileName;
		// $this->mail->AddAttachment($attach_file);
		//Display HTML Y/N
		$this->mail->IsHTML(true);

		if(!empty($msg)){
			$message = $msg;
		} else {

            $message1  = 'Dear '.$getInfo->super_name.'
';
            $message2  = '

REPORTED BY	            :	    '.$getInfo->Ename.'

EDITTED BY	            :	    '.$ccName.'

NCR ID	            :	    '.$pdqID.'

';
            $message3 = '

OBSERVATION	            :	    '.$getInfo->basic_description.'

';
             $message4 = '

ACTION ITEM	            :

';

            $message5 ='

                    No.
                    Responsible
                    Details
                    Expected Closing
                    Status

';
            foreach ($getImme as $value) {
            $message5 .='

            		'.$value->imeItem.'
            		'.$value->ime_responsible.'
                    '.$value->ime_actionItem.'
                    '.$value->ime_expected.'
                    '.$value->ime_status.'

';
            }
            $message5 .='
';

            $message6 = '

VISIT NCR REPORT LINK	            :	   Click Here

';

             $message7 = '

Best Regards,
'.$ccName.'
'.$getInfo->emp_jobfunction;
            //	$message = 'You Have A New PDQ Report From '.$ccName.'
PDQ ID : '.$pdqID.'
Observation : '.$getInfo->basic_description.'
Please Check -> http://vause.dyndns-server.com:8888/online_report/pdquser/index.html
';
		}
		//Body Message:
		$this->mail->Body = $message1.$message2.$message3.$message4.$message5.$message6.$message7;
		//Sent.....
		if(!$this->mail->Send())
		{
			return 'Error';
		}
		else
		{
			return 'Message has been sent';
		}

	}

public function sendMailNCRAttachment($emailTo,$emailName,$ccTo,$ccName,$pdqID){
       //mpdf//
        $ncrInfo = new NcrbasicinfoService();
        $pdqInfo = new PdqinfoService();
        $Immediate = new PdqimmediateactionService();
        $empAdress = new ReportsService();

        $getInfoNcr = $ncrInfo->getNcr_basicinfoByID($pdqID);
        $getInfo = $pdqInfo->getAllPdq_basicinfoAdvancedBypdqID($pdqID);
        $getImme = $Immediate->getPdq_immediateactionByPDQID($pdqID);
        $getAddress = $empAdress->getAddress($getInfo->empID);

        $check = '../pdquser/upload_images/checkbox_yes.png';
        $uncheck = '../pdquser/upload_images/checkbox_no.png';
        $imgDefault = '../pdquser/upload_images/default.png';
        $logoVause = '../pdquser/upload_images/logo-pdf.jpg';

      if($getInfo->basic_image1===NULL){
            $imgsrc1 = $imgDefault;
            $evident1 = ' ';
        }else{
            $imgsrc1 = '../pdquser/upload_images/'.$getInfo->basic_image1;
            $evident1 = 'Evident1';
        }
        if($getInfo->basic_image2===NULL){
            $imgsrc2 = $imgDefault;
            $evident2 = ' ';
        }else{
            $imgsrc2 = '../pdquser/upload_images/'.$getInfo->basic_image2;
            $evident2 = 'Evident2';
        }
        if($getInfo->basic_4===NULL){
            $imgsrc3 = $imgDefault;
            $evident3 = ' ';
        }else{
            $imgsrc3 = '../pdquser/upload_images/'.$getInfo->basic_4;
            $evident3 = 'Evident3';
        }
        if($getInfo->basic_5===NULL){
            $imgsrc4 = $imgDefault;
            $evident4 = ' ';
        }else{
            $imgsrc4 = '../pdquser/upload_images/'.$getInfo->basic_5;
            $evident4 = 'Evident4';
        }

         if($getInfoNcr->ncr_type==='1'){
            $Major = $check;
            $Minor = $uncheck;
        }else{
            $Major = $uncheck;
            $Minor = $check;
        }

        if($getInfoNcr->ncr_cusComplaint==='1'){
            $Yes = $check;
            $No = $uncheck;
        }else{
            $Yes = $uncheck;
            $No = $check;
        }
        if($getInfoNcr->ncr_proposedAction === '1') {
            $Accepted = $check;
            $Rejected = $uncheck;
        }if($getInfoNcr->ncr_proposedAction === '0'){
            $Accepted = $uncheck;
            $Rejected = $check;
        }else{
            $Accepted = $uncheck;
            $Rejected = $uncheck;
        }

$mpdf = new mPDF('c','A3','','',15,15,30,25,10,10);
$mpdf->SetHTMLHeader('

'.$getAddress->companyname.'

Non Conformance Report

		');
/** VAUSE WIRELINE SERVICES LTD. */
$aradd = preg_split("/[.]/", $getAddress->address,2,PREG_SPLIT_DELIM_CAPTURE);
$mpdf->SetHTMLFooter('

F-HSEQ-20

REV.02

');

$htmlinfo ='

		';
$htmlinfo .= '

Customer	            :	    '.$getInfo->client.'

Well	                 :	    '.$getInfoNcr->ncr_well.'

NCR No	               :	    '.$getInfoNcr->ncrID.'

Location	            :	    '.$getInfo->location.'

Department	           :	    '.$getInfo->business.'

NCR Case	             :
                	Minor
                	Major

Purchase Order No	   :	    '.$getInfoNcr->ncr_purchaseOrder.'

Vender / Supplier	  :	    '.$getInfoNcr->ncr_vender.'

Customer Complaint	 :
                    	No
                    	Yes

Compliance	   :	    '.$getInfoNcr->imsprocess.' '.$getInfoNcr->compliance.'

Lost Time	  :	    '.$getInfoNcr->ncr_losttime.'

Event Date	  :	    '.$getInfo->basic_eventDate.'

';
$htmlinfo .='

Brief Descriptions	              :	    '.$getInfoNcr->ncr_brief.'

';

$htmlinfo .='

Process	              :	    '.$getInfoNcr->ncr_process.'

';
$htmldesc ='

             	  DESCRIPTIONS

';
$htmldesc .='

Related Equipment	  :	  '.$getInfoNcr->ncr_equipment.'

Crews	             :	  '.$getInfoNcr->ncr_crews.'

Details	          :	  '.$getInfo->basic_description.'

Decision Making	 :	 '.$getInfoNcr->deposition.'

';
$htmldesc .='

Decided by	   :	    '.$getInfoNcr->ncr_approvedName.'

Approved by	   :	    _________________

Date : '.$getInfoNcr->ncr_approvedDate.'

';

if($getInfo->basic_image1 !== NULL){
$htmlevident ='

             	  EVIDENT

';
}
$htmlevident .='

            '.$getInfo->basic_7.'
            '.$getInfo->basic_8.'
            '.$getInfo->basic_9.'
            '.$getInfo->basic_10.'

';
$htmlevident .='
';
$htmlevident .='

            '.$getInfoNcr->ncr_1.'
            '.$getInfoNcr->ncr_2.'
            '.$getInfoNcr->ncr_3.'
            '.$getInfoNcr->ncr_4.'

';

$htmlroot ='

             	  TROUBLESHOOTING ROOT CAUSE & CORRECTIVE ACTION

';
$htmlroot .='

(Action must include cause, analysis, corrective action taken and action to prevent reoccurrence)

Troubleshooting :

'.$getInfoNcr->ncr_troubleshooting.'

Root Cause :

'.$getInfoNcr->ncr_rootCause.'

Action Items :

';

$htmlimme ='

        No.
        Responsible
        Details
        Expected Closing
        Status

';
foreach ($getImme as $value) {
$htmlimme .='

		'.$value->imeItem.'
		'.$value->ime_responsible.'
        '.$value->ime_actionItem.'
        '.$value->ime_expected.'
        '.$value->ime_status.'

';
}
$htmlimme .='
';
$htmlimme .='

Reported by	     :	 '.$getInfo->Ename.' - '.$getInfo->emp_jobfunction.'

____________________

Date : '.$getInfo->basic_eventDate.'

';

$htmlprop ='

                                   PROPOSED ACTION (If rejected give reason for rejection and alternate action required)
                                 	Accepted
                                 	Rejected

';
$htmlprop .='

Details	  :	  '.$getInfoNcr->ncr_proposedDesc.'

';
$htmlprop .='

Signed by	  :	  '.$getInfoNcr->ncr_proposedName.' - '.$getInfoNcr->ncr_proposedPosition.'

Closed by Division Manager	   :	  '.$getInfoNcr->ncr_divisionName.'

Closed by HSE & Q Manager	    :	  '.$getInfoNcr->ncr_hseqName.'

Date : '.$getInfoNcr->ncr_proposedDate.'

Date : _________

Date : _________

';

$html = $htmlinfo.$htmldesc.$htmlevident.$htmlroot.$htmlimme.$htmlprop;
        $mpdf->AddPage();
        $mpdf->WriteHTML($html);
        $name = $getInfoNcr->ncrID.'.pdf';
        $content = $mpdf->Output('', 'S');

		$this->mail->CharSet = "utf-8";
		$this->mail->IsSMTP();
		$this->mail->SMTPDebug = 0;
		$this->mail->SMTPAuth = true;
		$this->mail->SMTPSecure = "tls";
		$this->mail->Host = "smtp.gmail.com"; // SMTP server
		$this->mail->Port = 587;
		$this->mail->Username = $this->email; // account SMTP
		$this->mail->Password = $this->pass; //  account SMTP
		//From:
		$this->mail->SetFrom($this->email, "NCR Report");
		//TO:
//        $this->mail->AddAddress($emailTo, $emailName);
//        $this->mail->AddCC("hseq.thailand@vause.co.th", "HSEQ");
//        $this->mail->AddCC($ccTo, $ccName);
        /** Test by*/
		$this->mail->AddAddress("patcharin@infomediacomm.com", "Patcharin");

		//ReplayTo:
		$this->mail->AddReplyTo($this->email, " ");
		//Subject:
		if(!empty($subject)){
		 	$sub = $subject;
		}  else  {
			$sub = 'by '.$ccName;
		}
		$this->mail->Subject = $sub;
		//Attachment:
		// $attach_file = "./".$strFileName;
		// $this->mail->AddAttachment($attach_file);
		//Display HTML Y/N
		$this->mail->IsHTML(true);

		if(!empty($msg)){
			$message = $msg;
		} else {

           $message1  = 'Dear '.$getInfo->super_name.'
';
            $message2  = '

REPORTED BY	            :	    '.$getInfo->Ename.'

EDITTED BY	            :	    '.$ccName.'

NCR ID	            :	    '.$getInfoNcr->ncrID.'

';
            $message3 = '

OBSERVATION	            :	    '.$getInfo->basic_description.'

';
             $message4 = '

ACTION ITEM	            :

';

            $message5 ='

                    No.
                    Responsible
                    Details
                    Expected Closing
                    Status

';
            foreach ($getImme as $value) {
            $message5 .='

            		'.$value->imeItem.'
            		'.$value->ime_responsible.'
                    '.$value->ime_actionItem.'
                    '.$value->ime_expected.'
                    '.$value->ime_status.'

';
            }
            $message5 .='
';

            $message6 = '

VISIT NCR REPORT LINK	            :	   Click Here

';

             $message7 = '

Best Regards,
'.$ccName.'
'.$getInfo->emp_jobfunction;
            //	$message = 'You Have A New PDQ Report From '.$ccName.'
PDQ ID : '.$pdqID.'
Observation : '.$getInfo->basic_description.'
Please Check -> http://vause.dyndns-server.com:8888/online_report/pdquser/index.html
';
		}
		//Body Message:
		$this->mail->Body = $message1.$message2.$message3.$message4.$message5.$message6.$message7;
        $encoding = "base64";
        $type = "application/octet-stream";

        $this->mail->AddStringAttachment($content,$name);
        //$mpdf->Output($name,'D');
		//Sent.....
		if(!$this->mail->Send())
		{
			return 'Error';
		}
		else
		{
			return 'Message has been sent';
		}

	}

	public function  __destruct(){
		$this->mail = null;
	}

	public function test($format=null) {
			$rs = $this->SentMail('thongchai@servit.co.th','test','testagain');
			echo $rs;
	}
}

redpajama_set_name: RedPajamaGithub


text:
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse">
                Toggle navigation

            </button>

                <logo></logo>

{{ statistics[0] }}

{{ statistics[1] }}

                    {{ currentUser.name }}

View Profile

Manage Projects

Account Settings

 Logout


text:
"use strict";

const justJoin = require("../../src/arrayToRegex/justJoin");

describe("arrayToRegex/justJoin", () => {
  it("deve apenas juntar uma array", () => {
    expect(justJoin(["foo", "bar", "baz"])).toBe("(foobarbaz)");
  });
});


text:
// ----- this file has been automatically generated - do not edit
import { UAObject, UAMethod, UAProperty } from "node-opcua-address-space-base"
import { DataType } from "node-opcua-variant"
import { QualifiedName } from "node-opcua-data-model"
import { DTArgument } from "node-opcua-nodeset-ua/source/dt_argument"
import { UAFolder } from "node-opcua-nodeset-ua/source/ua_folder"
import { DTResult } from "./dt_result"
/**
 * The ResultManagementType provides mechanism to
 * access results generated by the underlying
 * system. Results can be managed in a local result
 * store of the Server. Methods and Objects with
 * Variables as well as Events and external file
 * stores can be used to provide the results to the
 * Client.
 *
 * |                |                                                  |
 * |----------------|--------------------------------------------------|
 * |namespace       |http://opcfoundation.org/UA/IJT/                  |
 * |nodeClass       |ObjectType                                        |
 * |typedDefinition |14:ResultManagementType ns=14;i=1017              |
 * |isAbstract      |false                                             |
 */
export interface UAResultManagement_Base {
    /**
     * defaultInstanceBrowseName
     * The default BrowseName for instances of the type.
     */
    defaultInstanceBrowseName: UAProperty<QualifiedName, DataType.QualifiedName>;
    getLatestResult?: UAMethod;
    getResultById?: UAMethod;
    getResultListFiltered?: UAMethod;
    releaseResultHandle?: UAMethod;
    /**
     * results
     * This is an instance of FolderType and is used to
     * organize multiple available results in the
     * underlying system which the server decides to
     * expose in the Address Space. It may contain no
     * results if the server does not expose results in
     * the Address Space at all or if no available
     * result matches the criteria for exposure in the
     * Address Space.
     */
    results?: UAFolder;
}
export interface UAResultManagement extends UAObject, UAResultManagement_Base {
}


text:
================
django-skd-smoke
================

.. image:: https://travis-ci.org/steelkiwi/django-skd-smoke.svg
    :target: https://travis-ci.org/steelkiwi/django-skd-smoke

.. image:: https://coveralls.io/repos/steelkiwi/django-skd-smoke/badge.svg?branch=master&service=github
    :target: https://coveralls.io/github/steelkiwi/django-skd-smoke?branch=master

.. image:: https://img.shields.io/pypi/l/django-skd-smoke.svg
    :target: https://pypi.python.org/pypi/django-skd-smoke

.. image:: https://img.shields.io/pypi/v/django-skd-smoke.svg
    :target: https://pypi.python.org/pypi/django-skd-smoke

.. image:: https://img.shields.io/pypi/pyversions/django-skd-smoke.svg
    :target: https://pypi.python.org/pypi/django-skd-smoke

This package is intended for simplification of smoke tests creation.

.. contents::

Installation
------------

You can get django-skd-smoke by using pip::

    $ pip install django-skd-smoke

Usage
-----
After installation you should create new ``TestCase`` derived from
``skd_smoke.SmokeTestCase`` and define your smoke tests configuration.
Please review `Examples`_ section which demonstrates different usecases.
They are related to ``example_project`` directory which contains common
django project.

Configuration
-------------
``TESTS_CONFIGURATION`` of your ``TestCase`` should contain tuple/list of
tuples for every request with the next structure:

.. code-block:: python

    (url, status, method, {'comment': None, 'initialize': None,
                           'url_kwargs': None, 'request_data': None,
                           'user_credentials': None, 'redirect_to': None})

.. list-table::
   :widths: 15 80 5
   :header-rows: 1

   * - Parameter
     - Description
     - Required
   * - url
     - plain url or urlname as string
     - Yes
   * - status
     - expected http status code (200, 404, etc.) as ``int``
     - Yes
   * - method
     - http request method (GET, POST, etc.) as string
     - Yes
   * - comment
     - string which is added to ``__doc__`` of generated test method
     - No
   * - initialize
     - callable object to do any required initialization
     - No
   * - url_args
     - list or callable object which returns args list to resolve url using ``django.shortcuts.resolve_url``
     - No
   * - url_kwargs
     - dict or callable object which returns kwargs dict to resolve url using ``django.shortcuts.resolve_url``
     - No
   * - request_data
     - dict or callable object which returns dict to pass it into http method request
     - No
   * - user_credentials
     - dict or callable object which returns dict to login user using ``django.test.TestCase.client.login``
     - No
   * - redirect_to
     - plain url as string which is checked if only status is one of the next: 301, 302, 303, 307
     - No

**NOTE!** All callables take your ``TestCase`` as the first argument so
you can use it to transfer state between them. But take into account that
**order of callbacks usage** is next:

#. ``initialize``
#. ``url_kwargs``
#. ``user_credentials``
#. ``request_data``

Examples
--------

All examples are taken from ``example_project`` package and can be run after
repository cloning.

\1. Demonstration of simple requests:
    1. GET 200
    2. GET 200 with request_data as dict
    3. POST 200
    4. POST 302 with request_data as callable
    5. GET 302 (unauthorized access)
    6. GET 200 (authorized access)
    7. POST 405 (method not allowed)

.. code-block:: python

    from django.contrib.auth import get_user_model

    from skd_smoke import SmokeTestCase

    def get_article_data(testcase):
        return {'headline': 'new article'}

    def get_user_credentials(testcase):
        username = 'test_user'
        password = '1234'
        credentials = {'username': username, 'password': password}
        User = get_user_model()
        new_user = User.objects.create(username=username)
        new_user.set_password(password)
        new_user.save()
        testcase.user = new_user
        return credentials

    class SimpleSmokeTestCase(SmokeTestCase):
        TESTS_CONFIGURATION = (
            ('home', 200, 'GET',),  # 1
            ('home', 200, 'GET', {'request_data': {'scrollTop': 1}}),  # 2
            ('articles:create', 200, 'POST',),  # 3
            ('articles:create', 302, 'POST',
             {'request_data': get_article_data}),  # 4
            ('is_authenticated', 302, 'GET',),  # 5
            ('is_authenticated', 200, 'GET',
             {'user_credentials': get_user_credentials}),  # 6
            ('/only_post_request/', 405, 'GET',),  # 7
        )

2. Usage of ``initialize`` callback to create several objects to test objects
list.

Suppose you want to make smoke test for articles list page but initially your
test db does not contain any. You can use ``initialize`` callback here to
create several articles.

.. code-block:: python

    from skd_smoke import SmokeTestCase

    from articles.models import Article

    def create_articles(testcase):
        for i in range(3):
            Article.objects.create(headline='article #%s' % i)

    class ArticlesListSmokeTestCase(SmokeTestCase):
        TESTS_CONFIGURATION = (
            ('articles:articles', 200, 'GET',
                {'initialize': create_articles}  # pass your func here
            ),
        )

3. Usage of ``redirect_to`` setting to test anonymous access of login required
pages.

.. code-block:: python

    from django.core.urlresolvers import reverse

    from skd_smoke import SmokeTestCase

    class RedirectToSmokeTestCase(SmokeTestCase):
        TESTS_CONFIGURATION = (
            ('is_authenticated', 302, 'GET', {
                'redirect_to': '%s?next=%s' % (reverse('login'),
                                               reverse('is_authenticated')),
                'comment': 'Anonymous profile access with check of redirect url'
            }),
        )

4. Usage of ``url_kwargs`` and ``user_credentials`` callbacks to test
authorized access of owner to newly created object.

Suppose you have a model Article which unpublished version can be viewed by
its owner only. You can test this situation by creating of user in
``url_kwargs`` callback and transfering user to ``user_credentials`` callback.
Unfortunately, you cannot get password from user model cause it contains
hashed password. So you should return password as plain text.

Lets smoke test two other situations when 404 page is showed. Finally we have
three testcases:

i. Anonymous access should show 404 page.
ii. Some ordinary user access should also show 404 page.
iii. Only owner access returns actual article with status 200.

.. code-block:: python

    from django.contrib.auth import get_user_model

    from skd_smoke import SmokeTestCase

    from articles.models import Article

    def create_user():
        UserModel = get_user_model()
        new_user = UserModel.objects.create(username='test_user')
        new_user.set_password('1234')
        new_user.save()
        return new_user

    def create_unpublished_article(commit=True):
        article = Article(headline='unpublished', published=False)
        if commit:
            article.save()
        return article

    def create_article_without_owner(testcase):
        return {'pk': create_unpublished_article().pk}

    def create_and_return_user_credentials(testcase):
        user = create_user()
        return {
            'username': user.username,
            'password': '1234'  # User contains hashed password only so we should
                                # return it as plain text
        }

    def create_article_with_its_owner(testcase):
        owner = create_user()
        testcase.owner = owner
        unpublished = create_unpublished_article(commit=False)
        unpublished.owner = owner
        unpublished.save()
        return {'pk': unpublished.pk}

    def get_owner_credentials(testcase):
        return {
            'username': testcase.owner.username,
            'password': '1234'  # User contains hashed password only
        }

    class UnpublishedArticleSmokeTestCase(SmokeTestCase):
        TESTS_CONFIGURATION = (
            ('articles:article', 404, 'GET',
                {'url_kwargs': create_article_without_owner,
                 'comment': 'Anonymous access to unpublished article.'}),  # 1

            ('articles:article', 404, 'GET',
                {'url_kwargs': create_article_without_owner,
                 'user_credentials': create_and_return_user_credentials,
                 'comment': 'Some user access to unpublished article.'}),  # 2

            ('articles:article', 200, 'GET',
                {'url_kwargs': create_article_with_its_owner,
                 'user_credentials': get_owner_credentials,
                 'comment': 'Owner access to unpublished article.'}),  # 3
        )

License
-------

MIT


text:
module Mongoid #:nodoc:

  # This module contains all the callback hooks for Mongoid.
  module Callbacks
    extend ActiveSupport::Concern

    CALLBACKS = [
      :before_validation, :after_validation,
      :after_initialize, :after_build,
      :before_create, :around_create, :after_create,
      :before_destroy, :around_destroy, :after_destroy,
      :before_save, :around_save, :after_save,
      :before_update, :around_update, :after_update,
    ]

    included do
      extend ActiveModel::Callbacks
      include ActiveModel::Validations::Callbacks

      define_model_callbacks :initialize, only: :after
      define_model_callbacks :build, only: :after
      define_model_callbacks :create, :destroy, :save, :update
    end

    # Run the callbacks for the document. This overrides active support's
    # functionality to cascade callbacks to embedded documents that have been
    # flagged as such.
    #
    # @example Run the callbacks.
    #   run_callbacks :save do
    #     save!
    #   end
    #
    # @param [ Symbol ] kind The type of callback to execute.
    # @param [ Array ] *args Any options.
    #
    # @return [ Document ] The document
    #
    # @since 2.3.0
    def run_callbacks(kind, *args, &block)
      cascadable_children(kind).each do |child|
        child.run_callbacks(child_callback_type(kind, child), *args)
      end
      super(kind, *args, &block)
    end

    private

    # Get all the child embedded documents that are flagged as cascadable.
    #
    # @example Get all the cascading children.
    #   document.cascadable_children(:update)
    #
    # @param [ Symbol ] kind The type of callback.
    #
    # @return [ Array<Document> ] The children.
    #
    # @since 2.3.0
    def cascadable_children(kind, children = Set.new)
      relations.each_pair do |name, metadata|
        next unless metadata.cascading_callbacks?
        without_autobuild do
          delayed_pulls = delayed_atomic_pulls[name]
          children.merge(delayed_pulls) if delayed_pulls
          relation = send(name)
          Array.wrap(relation).each do |child|
            next if children.include?(child)
            children.add(child) if cascadable_child?(kind, child)
            children.merge(child.send(:cascadable_children, kind, children))
          end
        end
      end
      children.to_a
    end

    # Determine if the child should fire the callback.
    #
    # @example Should the child fire the callback?
    #   document.cascadable_child?(:update, doc)
    #
    # @param [ Symbol ] kind The type of callback.
    # @param [ Document ] child The child document.
    #
    # @return [ true, false ] If the child should fire the callback.
    #
    # @since 2.3.0
    def cascadable_child?(kind, child)
      return false if kind == :initialize || !child.respond_to?("_#{kind}_callbacks")
      [ :create, :destroy ].include?(kind) || child.changed? || child.new_record?
    end

    # Get the name of the callback that the child should fire. This changes
    # depending on whether or not the child is new. A persisted parent with a
    # new child would fire :update from the parent, but needs to fire :create
    # on the child.
    #
    # @example Get the callback type.
    #   document.child_callback_type(:update, doc)
    #
    # @param [ Symbol ] kind The type of callback.
    # @param [ Document ] child The child document
    #
    # @return [ Symbol ] The name of the callback.
    #
    # @since 2.3.0
    def child_callback_type(kind, child)
      if kind == :update
        return :create if child.new_record?
        return :destroy if child.flagged_for_destroy?
        kind
      else
        kind
      end
    end
  end
end


text:
#ifndef BOOST_PREPROCESSOR_LIST_HPP
#define BOOST_PREPROCESSOR_LIST_HPP

/**
Includes all list headers.
 */

#include <boost/preprocessor/list/append.hpp>
#include <boost/preprocessor/list/at.hpp>
#include <boost/preprocessor/list/cat.hpp>
#include <boost/preprocessor/list/filter.hpp>
#include <boost/preprocessor/list/first_n.hpp>
#include <boost/preprocessor/list/fold_right_2nd.hpp>
#include <boost/preprocessor/list/for_each.hpp>
#include <boost/preprocessor/list/for_each_product.hpp>
#include <boost/preprocessor/list/size.hpp>
#include <boost/preprocessor/list/to_tuple.hpp>
#include <boost/preprocessor/list/transform.hpp>
#endif


text:
/* eslint-env mocha */

import { formatter } from '../src/toga-markdown';
import expect from 'expect';

describe('toga-markdown spec', function () {
	describe('formatter', function () {
		it('should return a transform stream', function () {
			var retval = formatter();

			expect(retval.pipe).toBeA(Function);
			expect(retval.readable).toBe(true);
			expect(retval.writable).toBe(true);
		});
	});
});


text:
// Boost.Geometry (aka GGL, Generic Geometry Library)

// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.

// This file was modified by Oracle on 2013, 2014.
// Modifications copyright (c) 2013-2014 Oracle and/or its affiliates.

// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_LA_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_LA_HPP

#include <boost/geometry/algorithms/detail/overlay/get_turn_info.hpp>
#include <boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp>

// TEMP, for spikes detector
//#include <boost/geometry/algorithms/detail/overlay/get_turn_info_ll.hpp>

namespace boost { namespace geometry {

#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace overlay {

template<typename AssignPolicy>
struct get_turn_info_linear_areal
{
    static const bool handle_spikes = true;

    template
    <
        typename Point1,
        typename Point2,
        typename TurnInfo,
        typename RobustPolicy,
        typename OutputIterator
    >
    static inline OutputIterator apply(
                Point1 const& pi, Point1 const& pj, Point1 const& pk,
                Point2 const& qi, Point2 const& qj, Point2 const& qk,
                bool is_p_first, bool is_p_last,
                bool is_q_first, bool is_q_last,
                TurnInfo const& tp_model,
                RobustPolicy const& robust_policy,
                OutputIterator out)
    {
        typedef intersection_info<Point1, Point2, typename TurnInfo::point_type, RobustPolicy>
            inters_info;

        inters_info inters(pi, pj, pk, qi, qj, qk, robust_policy);

        char const method = inters.d_info().how;

        // Copy, to copy possibly extended fields
        TurnInfo tp = tp_model;

        // Select method and apply
        switch(method)
        {
            case 'a' : // collinear, "at"
            case 'f' : // collinear, "from"
            case 's' : // starts from the middle
                get_turn_info_for_endpoint<true, true>(
                    pi, pj, pk, qi, qj, qk,
                    is_p_first, is_p_last, is_q_first, is_q_last,
                    tp_model, inters, method_none, out);
                break;

            case 'd' : // disjoint: never do anything
                break;

            case 'm' :
            {
                if ( get_turn_info_for_endpoint<false, true>(
                        pi, pj, pk, qi, qj, qk,
                        is_p_first, is_p_last, is_q_first, is_q_last,
                        tp_model, inters, method_touch_interior, out) )
                {
                    // do nothing
                }
                else
                {
                    typedef touch_interior
                        <
                            TurnInfo
                        > policy;

                    // If Q (1) arrives (1)
                    if ( inters.d_info().arrival[1] == 1 )
                    {
                        policy::template apply<0>(pi, pj, pk, qi, qj, qk,
                                    tp, inters.i_info(), inters.d_info(),
                                    inters.sides());
                    }
                    else
                    {
                        // Swap p/q
                        side_calculator
                            <
                                typename inters_info::robust_point2_type,
                                typename inters_info::robust_point1_type
                            > swapped_side_calc(inters.rqi(), inters.rqj(), inters.rqk(),
                                                inters.rpi(), inters.rpj(), inters.rpk());
                        policy::template apply<1>(qi, qj, qk, pi, pj, pk,
                                    tp, inters.i_info(), inters.d_info(),
                                    swapped_side_calc);
                    }

                    if ( tp.operations[1].operation == operation_blocked )
                    {
                        tp.operations[0].is_collinear = true;
                    }

                    replace_method_and_operations_tm(tp.method,
                                                     tp.operations[0].operation,
                                                     tp.operations[1].operation);

                    // this function assumes that 'u' must be set for a spike
                    calculate_spike_operation(tp.operations[0].operation,
                                              inters, is_p_last);

                    AssignPolicy::apply(tp, pi, qi, inters.i_info(), inters.d_info());

                    *out++ = tp;
                }
            }
            break;
            case 'i' :
            {
                crosses<TurnInfo>::apply(pi, pj, pk, qi, qj, qk,
                                         tp, inters.i_info(), inters.d_info());

                replace_operations_i(tp.operations[0].operation, tp.operations[1].operation);

                AssignPolicy::apply(tp, pi, qi, inters.i_info(), inters.d_info());
                *out++ = tp;
            }
            break;
            case 't' :
            {
                // Both touch (both arrive there)
                if ( get_turn_info_for_endpoint<false, true>(
                        pi, pj, pk, qi, qj, qk,
                        is_p_first, is_p_last, is_q_first, is_q_last,
                        tp_model, inters, method_touch, out) )
                {
                    // do nothing
                }
                else
                {
                    touch<TurnInfo>::apply(pi, pj, pk, qi, qj, qk,
                            tp, inters.i_info(), inters.d_info(), inters.sides());

                    if ( tp.operations[1].operation == operation_blocked )
                    {
                        tp.operations[0].is_collinear = true;
                    }

                    // workarounds for touch<> not taking spikes into account starts here
                    // those was discovered empirically
                    // touch<> is not symmetrical!
                    // P spikes and Q spikes may produce various operations!
                    // Only P spikes are valid for L/A
                    // TODO: this is not optimal solution - think about rewriting touch<>

                    if ( tp.operations[0].operation == operation_blocked )
                    {
                        // a spike on P on the same line with Q1
                        if ( inters.is_spike_p() )
                        {
                            if ( inters.sides().qk_wrt_p1() == 0 )
                            {
                                tp.operations[0].is_collinear = true;
                            }
                            else
                            {
                                tp.operations[0].operation = operation_union;
                            }
                        }
                    }
                    else if ( tp.operations[0].operation == operation_continue
                           && tp.operations[1].operation == operation_continue )
                    {
                        // P spike on the same line with Q2 (opposite)
                        if ( inters.sides().pk_wrt_q1() == -inters.sides().qk_wrt_q1()
                          && inters.is_spike_p() )
                        {
                            tp.operations[0].operation = operation_union;
                            tp.operations[1].operation = operation_union;
                        }
                    }
                    else if ( tp.operations[0].operation == operation_none
                           && tp.operations[1].operation == operation_none )
                    {
                        // spike not handled by touch<>
                        if ( inters.is_spike_p() )
                        {
                            tp.operations[0].operation = operation_intersection;
                            tp.operations[1].operation = operation_union;

                            if ( inters.sides().pk_wrt_q2() == 0 )
                            {
                                tp.operations[0].operation = operation_continue; // will be converted to i
                                tp.operations[0].is_collinear = true;
                            }
                        }
                    }

                    // workarounds for touch<> not taking spikes into account ends here

                    replace_method_and_operations_tm(tp.method,
                                                     tp.operations[0].operation,
                                                     tp.operations[1].operation);

                    bool ignore_spike
                        = calculate_spike_operation(tp.operations[0].operation,
                                                    inters, is_p_last);

// TODO: move this into the append_xxx and call for each turn?
                    AssignPolicy::apply(tp, pi, qi, inters.i_info(), inters.d_info());

                    if ( ! handle_spikes
                      || ignore_spike
                      || ! append_opposite_spikes<append_touches>( // for 'i' or 'c' i???
                                tp, inters, is_p_last, is_q_last, out) )
                    {
                        *out++ = tp;
                    }
                }
            }
            break;
            case 'e':
            {
                if ( get_turn_info_for_endpoint<true, true>(
                        pi, pj, pk, qi, qj, qk,
                        is_p_first, is_p_last, is_q_first, is_q_last,
                        tp_model, inters, method_equal, out) )
                {
                    // do nothing
                }
                else
                {
                    tp.operations[0].is_collinear = true;

                    if ( ! inters.d_info().opposite )
                    {
                        // Both equal
                        // or collinear-and-ending at intersection point
                        equal<TurnInfo>::apply(pi, pj, pk, qi, qj, qk,
                            tp, inters.i_info(), inters.d_info(), inters.sides());

                        turn_transformer_ec<false> transformer(method_touch);
                        transformer(tp);

// TODO: move this into the append_xxx and call for each turn?
                        AssignPolicy::apply(tp, pi, qi, inters.i_info(), inters.d_info());

                        // conditionally handle spikes
                        if ( ! handle_spikes
                          || ! append_collinear_spikes(tp, inters, is_p_last, is_q_last,
                                                       method_touch, append_equal, out) )
                        {
                            *out++ = tp; // no spikes
                        }
                    }
                    else
                    {
                        equal_opposite
                            <
                                TurnInfo,
                                AssignPolicy
                            >::apply(pi, qi,
                                     tp, out, inters.i_info(), inters.d_info());
                    }
                }
            }
            break;
            case 'c' :
            {
                // Collinear
                if ( get_turn_info_for_endpoint<true, true>(
                        pi, pj, pk, qi, qj, qk,
                        is_p_first, is_p_last, is_q_first, is_q_last,
                        tp_model, inters, method_collinear, out) )
                {
                    // do nothing
                }
                else
                {
                    tp.operations[0].is_collinear = true;

                    if ( ! inters.d_info().opposite )
                    {
                        method_type method_replace = method_touch_interior;
                        append_version_c version = append_collinear;

                        if ( inters.d_info().arrival[0] == 0 )
                        {
                            // Collinear, but similar thus handled as equal
                            equal<TurnInfo>::apply(pi, pj, pk, qi, qj, qk,
                                    tp, inters.i_info(), inters.d_info(), inters.sides());

                            method_replace = method_touch;
                            version = append_equal;
                        }
                        else
                        {
                            collinear<TurnInfo>::apply(pi, pj, pk, qi, qj, qk,
                                    tp, inters.i_info(), inters.d_info(), inters.sides());

                            //method_replace = method_touch_interior;
                            //version = append_collinear;
                        }

                        turn_transformer_ec<false> transformer(method_replace);
                        transformer(tp);

// TODO: move this into the append_xxx and call for each turn?
                        AssignPolicy::apply(tp, pi, qi, inters.i_info(), inters.d_info());

                        // conditionally handle spikes
                        if ( ! handle_spikes
                          || ! append_collinear_spikes(tp, inters, is_p_last, is_q_last,
                                                       method_replace, version, out) )
                        {
                            // no spikes
                            *out++ = tp;
                        }
                    }
                    else
                    {
                        // Is this always 'm' ?
                        turn_transformer_ec<false> transformer(method_touch_interior);

                        // conditionally handle spikes
                        if ( handle_spikes )
                        {
                            append_opposite_spikes<append_collinear_opposite>(
                                    tp, inters, is_p_last, is_q_last, out);
                        }

                        // TODO: ignore for spikes?
                        //       E.g. pass is_p_valid = !is_p_last && !is_pj_spike,
                        //       the same with is_q_valid

                        collinear_opposite
                            <
                                TurnInfo,
                                AssignPolicy
                            >::apply(pi, pj, pk, qi, qj, qk,
                                tp, out, inters.i_info(), inters.d_info(),
                                inters.sides(), transformer);
                    }
                }
            }
            break;
            case '0' :
            {
                // degenerate points
                if (AssignPolicy::include_degenerate)
                {
                    only_convert::apply(tp, inters.i_info());

                    if ( is_p_first
                      && equals::equals_point_point(pi, tp.point) )
                    {
                        tp.operations[0].position = position_front;
                    }
                    else if ( is_p_last
                           && equals::equals_point_point(pj, tp.point) )
                    {
                        tp.operations[0].position = position_back;
                    }
                    // tp.operations[1].position = position_middle;

                    AssignPolicy::apply(tp, pi, qi, inters.i_info(), inters.d_info());
                    *out++ = tp;
                }
            }
            break;
            default :
            {
#if defined(BOOST_GEOMETRY_DEBUG_ROBUSTNESS)
                std::cout << "TURN: Unknown method: " << method << std::endl;
#endif
#if ! defined(BOOST_GEOMETRY_OVERLAY_NO_THROW)
                throw turn_info_exception(method);
#endif
            }
            break;
        }

        return out;
    }

    template <typename Operation,
              typename IntersectionInfo>
    static inline bool calculate_spike_operation(Operation & op,
                                                 IntersectionInfo const& inters,
                                                 bool is_p_last)
    {
        bool is_p_spike = ( op == operation_union || op == operation_intersection )
                       && ! is_p_last
                       && inters.is_spike_p();

        if ( is_p_spike )
        {
            bool going_in = false, going_out = false;

            int const pk_q1 = inters.sides().pk_wrt_q1();
            int const pk_q2 = inters.sides().pk_wrt_q2();

            if ( inters.sides().qk_wrt_q1() <= 0 ) // Q turning R or C
            {
                going_in = pk_q1 < 0 && pk_q2 < 0; // Pk on the right of both
                going_out = pk_q1 > 0 || pk_q2 > 0; // Pk on the left of one of them
            }
            else
            {
                going_in = pk_q1 < 0 || pk_q2 < 0; // Pk on the right of one of them
                going_out = pk_q1 > 0 && pk_q2 > 0; // Pk on the left of both
            }

            if ( going_in )
            {
                op = operation_intersection;
                return true;
            }
            else if ( going_out )
            {
                op = operation_union;
                return true;
            }
        }

        return false;
    }

    enum append_version_c { append_equal, append_collinear };

    template <typename TurnInfo,
              typename IntersectionInfo,
              typename OutIt>
    static inline bool append_collinear_spikes(TurnInfo & tp,
                                               IntersectionInfo const& inters,
                                               bool is_p_last, bool /*is_q_last*/,
                                               method_type method, append_version_c version,
                                               OutIt out)
    {
        // method == touch || touch_interior
        // both position == middle

        bool is_p_spike = ( version == append_equal ?
                            ( tp.operations[0].operation == operation_union
                           || tp.operations[0].operation == operation_intersection ) :
                            tp.operations[0].operation == operation_continue )
                       && ! is_p_last
                       && inters.is_spike_p();

        // TODO: throw an exception for spike in Areal?
        /*bool is_q_spike = tp.operations[1].operation == spike_op
                       && ! is_q_last
                       && inters.is_spike_q();*/

        if ( is_p_spike )
        {
            tp.method = method;
            tp.operations[0].operation = operation_blocked;
            tp.operations[1].operation = operation_union;
            *out++ = tp;
            tp.operations[0].operation = operation_continue; // boundary
            //tp.operations[1].operation = operation_union;
            *out++ = tp;

            return true;
        }

        return false;
    }

    enum append_version_o { append_touches, append_collinear_opposite };

    template <append_version_o Version,
              typename TurnInfo,
              typename IntersectionInfo,
              typename OutIt>
    static inline bool append_opposite_spikes(TurnInfo & tp,
                                              IntersectionInfo const& inters,
                                              bool is_p_last, bool /*is_q_last*/,
                                              OutIt out)
    {
        bool is_p_spike = ( Version == append_touches ?
                            ( tp.operations[0].operation == operation_continue
                           || tp.operations[0].operation == operation_intersection ) : // i ???
                            true )
                       && ! is_p_last
                       && inters.is_spike_p();
        // TODO: throw an exception for spike in Areal?
        /*bool is_q_spike = ( Version == append_touches ?
                            ( tp.operations[1].operation == operation_continue
                           || tp.operations[1].operation == operation_intersection ) :
                            true )
                       && ! is_q_last
                       && inters.is_spike_q();*/

        if ( is_p_spike && ( Version == append_touches || inters.d_info().arrival[0] == 1 ) )
        {
            if ( Version == append_touches )
            {
                tp.operations[0].is_collinear = true;
                //tp.operations[1].is_collinear = false;
                tp.method = method_touch;
            }
            else
            {
                tp.operations[0].is_collinear = true;
                //tp.operations[1].is_collinear = false;

                BOOST_ASSERT(inters.i_info().count > 1);
                base_turn_handler::assign_point(tp, method_touch_interior, inters.i_info(), 1);

                AssignPolicy::apply(tp, inters.pi(), inters.qi(), inters.i_info(), inters.d_info());
            }

            tp.operations[0].operation = operation_blocked;
            tp.operations[1].operation = operation_continue; // boundary
            *out++ = tp;
            tp.operations[0].operation = operation_continue; // boundary
            //tp.operations[1].operation = operation_continue; // boundary
            *out++ = tp;

            return true;
        }

        return false;
    }

    static inline void replace_method_and_operations_tm(method_type & method,
                                                        operation_type & op0,
                                                        operation_type & op1)
    {
        if ( op0 == operation_blocked && op1 == operation_blocked )
        {
            // NOTE: probably only if methods are WRT IPs, not segments!
            method = (method == method_touch ? method_equal : method_collinear);
        }

        // Assuming G1 is always Linear
        if ( op0 == operation_blocked )
        {
            op0 = operation_continue;
        }

        if ( op1 == operation_blocked )
        {
            op1 = operation_continue;
        }
        else if ( op1 == operation_intersection )
        {
            op1 = operation_union;
        }

        // spikes in 'm'
        if ( method == method_error )
        {
            method = method_touch_interior;
            op0 = operation_union;
            op1 = operation_union;
        }
    }

    template <bool IsFront>
    class turn_transformer_ec
    {
    public:
        explicit turn_transformer_ec(method_type method_t_or_m)
            : m_method(method_t_or_m)
        {}

        template <typename Turn>
        void operator()(Turn & turn) const
        {
            operation_type & op0 = turn.operations[0].operation;
            operation_type & op1 = turn.operations[1].operation;

            // NOTE: probably only if methods are WRT IPs, not segments!
            if ( IsFront
              || op0 == operation_intersection || op0 == operation_union
              || op1 == operation_intersection || op1 == operation_union )
            {
                turn.method = m_method;
            }

            turn.operations[0].is_collinear = op0 != operation_blocked;

            // Assuming G1 is always Linear
            if ( op0 == operation_blocked )
            {
                op0 = operation_continue;
            }

            if ( op1 == operation_blocked )
            {
                op1 = operation_continue;
            }
            else if ( op1 == operation_intersection )
            {
                op1 = operation_union;
            }
        }

    private:
        method_type m_method;
    };

    static inline void replace_operations_i(operation_type & /*op0*/, operation_type & op1)
    {
        // assuming Linear is always the first one
        op1 = operation_union;
    }

    // NOTE: Spikes may NOT be handled for Linear endpoints because it's not
    //       possible to define a spike on an endpoint. Areal geometries must
    //       NOT have spikes at all. One thing that could be done is to throw
    //       an exception when spike is detected in Areal geometry.

    template <bool EnableFirst,
              bool EnableLast,
              typename Point1,
              typename Point2,
              typename TurnInfo,
              typename IntersectionInfo,
              typename OutputIterator>
    static inline bool get_turn_info_for_endpoint(
                            Point1 const& pi, Point1 const& /*pj*/, Point1 const& /*pk*/,
                            Point2 const& qi, Point2 const& /*qj*/, Point2 const& /*qk*/,
                            bool is_p_first, bool is_p_last,
                            bool /*is_q_first*/, bool is_q_last,
                            TurnInfo const& tp_model,
                            IntersectionInfo const& inters,
                            method_type /*method*/,
                            OutputIterator out)
    {
        namespace ov = overlay;
        typedef ov::get_turn_info_for_endpoint<AssignPolicy, EnableFirst, EnableLast> get_info_e;

        const std::size_t ip_count = inters.i_info().count;
        // no intersection points
        if ( ip_count == 0 )
            return false;

        if ( !is_p_first && !is_p_last )
            return false;

// TODO: is_q_last could probably be replaced by false and removed from parameters

        linear_intersections intersections(pi, qi, inters.result(), is_p_last, is_q_last);
        linear_intersections::ip_info const& ip0 = intersections.template get<0>();
        linear_intersections::ip_info const& ip1 = intersections.template get<1>();

        const bool opposite = inters.d_info().opposite;

        // ANALYSE AND ASSIGN FIRST

        // IP on the first point of Linear Geometry
        if ( EnableFirst && is_p_first && ip0.is_pi && !ip0.is_qi ) // !q0i prevents duplication
        {
            TurnInfo tp = tp_model;
            tp.operations[0].position = position_front;
            tp.operations[1].position = position_middle;

            if ( opposite ) // opposite -> collinear
            {
                tp.operations[0].operation = operation_continue;
                tp.operations[1].operation = operation_union;
                tp.method = ip0.is_qj ? method_touch : method_touch_interior;
            }
            else
            {
                method_type replaced_method = method_touch_interior;

                if ( ip0.is_qj )
                {
                    side_calculator
                        <
                            typename IntersectionInfo::robust_point1_type,
                            typename IntersectionInfo::robust_point2_type,
                            typename IntersectionInfo::robust_point2_type
                        > side_calc(inters.rqi(), inters.rpi(), inters.rpj(),
                                    inters.rqi(), inters.rqj(), inters.rqk());

                    std::pair<operation_type, operation_type>
                        operations = get_info_e::operations_of_equal(side_calc);

                    tp.operations[0].operation = operations.first;
                    tp.operations[1].operation = operations.second;

                    replaced_method = method_touch;
                }
                else
                {
                    side_calculator
                        <
                            typename IntersectionInfo::robust_point1_type,
                            typename IntersectionInfo::robust_point2_type,
                            typename IntersectionInfo::robust_point2_type,
                            typename IntersectionInfo::robust_point1_type,
                            typename IntersectionInfo::robust_point1_type,
                            typename IntersectionInfo::robust_point2_type,
                            typename IntersectionInfo::robust_point1_type,
                            typename IntersectionInfo::robust_point2_type
                        > side_calc(inters.rqi(), inters.rpi(), inters.rpj(),
                                    inters.rqi(), inters.rpi(), inters.rqj());

                    std::pair<operation_type, operation_type>
                        operations = get_info_e::operations_of_equal(side_calc);

                    tp.operations[0].operation = operations.first;
                    tp.operations[1].operation = operations.second;
                }

                turn_transformer_ec<true> transformer(replaced_method);
                transformer(tp);
            }

            // equals<> or collinear<> will assign the second point,
            // we'd like to assign the first one
            base_turn_handler::assign_point(tp, tp.method, inters.i_info(), 0);

            // NOTE: is_collinear is not set for the first endpoint of L
            // for which there is no preceding segment
            // here is_p_first_ip == true
            tp.operations[0].is_collinear = false;

            AssignPolicy::apply(tp, pi, qi, inters.i_info(), inters.d_info());
            *out++ = tp;
        }

        // ANALYSE AND ASSIGN LAST

        // IP on the last point of Linear Geometry
        if ( EnableLast
          && is_p_last
          && ( ip_count > 1 ? (ip1.is_pj && !ip1.is_qi) : (ip0.is_pj && !ip0.is_qi) ) ) // prevents duplication
        {
            TurnInfo tp = tp_model;

            if ( inters.i_info().count > 1 )
            {
                //BOOST_ASSERT( result.template get<1>().dir_a == 0 && result.template get<1>().dir_b == 0 );
                tp.operations[0].is_collinear = true;
                tp.operations[1].operation = opposite ? operation_continue : operation_union;
            }
            else //if ( result.template get<0>().count == 1 )
            {
                side_calculator
                    <
                        typename IntersectionInfo::robust_point1_type,
                        typename IntersectionInfo::robust_point2_type,
                        typename IntersectionInfo::robust_point2_type
                    > side_calc(inters.rqi(), inters.rpj(), inters.rpi(),
                                inters.rqi(), inters.rqj(), inters.rqk());

                std::pair<operation_type, operation_type>
                    operations = get_info_e::operations_of_equal(side_calc);

                tp.operations[0].operation = operations.first;
                tp.operations[1].operation = operations.second;

                turn_transformer_ec<false> transformer(method_none);
                transformer(tp);

                tp.operations[0].is_collinear = tp.both(operation_continue);
            }

            tp.method = ( ip_count > 1 ? ip1.is_qj : ip0.is_qj ) ? method_touch : method_touch_interior;
            tp.operations[0].operation = operation_blocked;
            tp.operations[0].position = position_back;
            tp.operations[1].position = position_middle;

            // equals<> or collinear<> will assign the second point,
            // we'd like to assign the first one
            int ip_index = ip_count > 1 ? 1 : 0;
            base_turn_handler::assign_point(tp, tp.method, inters.i_info(), ip_index);

            AssignPolicy::apply(tp, pi, qi, inters.i_info(), inters.d_info());
            *out++ = tp;

            return true;
        }

        // don't ignore anything for now
        return false;
    }
};

}} // namespace detail::overlay
#endif // DOXYGEN_NO_DETAIL

}} // namespace boost::geometry

#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_LA_HPP


text:
#include <aws/fsx/model/Snapshot.h>
#include <aws/core/utils/json/JsonSerializer.h>

#include <utility>

using namespace Aws::Utils::Json;
using namespace Aws::Utils;

namespace Aws
{
namespace FSx
{
namespace Model
{

Snapshot::Snapshot() :
    m_resourceARNHasBeenSet(false),
    m_snapshotIdHasBeenSet(false),
    m_nameHasBeenSet(false),
    m_volumeIdHasBeenSet(false),
    m_creationTimeHasBeenSet(false),
    m_lifecycle(SnapshotLifecycle::NOT_SET),
    m_lifecycleHasBeenSet(false),
    m_lifecycleTransitionReasonHasBeenSet(false),
    m_tagsHasBeenSet(false),
    m_administrativeActionsHasBeenSet(false)
{
}

Snapshot::Snapshot(JsonView jsonValue) :
    m_resourceARNHasBeenSet(false),
    m_snapshotIdHasBeenSet(false),
    m_nameHasBeenSet(false),
    m_volumeIdHasBeenSet(false),
    m_creationTimeHasBeenSet(false),
    m_lifecycle(SnapshotLifecycle::NOT_SET),
    m_lifecycleHasBeenSet(false),
    m_lifecycleTransitionReasonHasBeenSet(false),
    m_tagsHasBeenSet(false),
    m_administrativeActionsHasBeenSet(false)
{
  *this = jsonValue;
}

Snapshot& Snapshot::operator =(JsonView jsonValue)
{
  if(jsonValue.ValueExists("ResourceARN"))
  {
    m_resourceARN = jsonValue.GetString("ResourceARN");

    m_resourceARNHasBeenSet = true;
  }

  if(jsonValue.ValueExists("SnapshotId"))
  {
    m_snapshotId = jsonValue.GetString("SnapshotId");

    m_snapshotIdHasBeenSet = true;
  }

  if(jsonValue.ValueExists("Name"))
  {
    m_name = jsonValue.GetString("Name");

    m_nameHasBeenSet = true;
  }

  if(jsonValue.ValueExists("VolumeId"))
  {
    m_volumeId = jsonValue.GetString("VolumeId");

    m_volumeIdHasBeenSet = true;
  }

  if(jsonValue.ValueExists("CreationTime"))
  {
    m_creationTime = jsonValue.GetDouble("CreationTime");

    m_creationTimeHasBeenSet = true;
  }

  if(jsonValue.ValueExists("Lifecycle"))
  {
    m_lifecycle = SnapshotLifecycleMapper::GetSnapshotLifecycleForName(jsonValue.GetString("Lifecycle"));

    m_lifecycleHasBeenSet = true;
  }

  if(jsonValue.ValueExists("LifecycleTransitionReason"))
  {
    m_lifecycleTransitionReason = jsonValue.GetObject("LifecycleTransitionReason");

    m_lifecycleTransitionReasonHasBeenSet = true;
  }

  if(jsonValue.ValueExists("Tags"))
  {
    Aws::Utils::Array<JsonView> tagsJsonList = jsonValue.GetArray("Tags");
    for(unsigned tagsIndex = 0; tagsIndex < tagsJsonList.GetLength(); ++tagsIndex)
    {
      m_tags.push_back(tagsJsonList[tagsIndex].AsObject());
    }
    m_tagsHasBeenSet = true;
  }

  if(jsonValue.ValueExists("AdministrativeActions"))
  {
    Aws::Utils::Array<JsonView> administrativeActionsJsonList = jsonValue.GetArray("AdministrativeActions");
    for(unsigned administrativeActionsIndex = 0; administrativeActionsIndex < administrativeActionsJsonList.GetLength(); ++administrativeActionsIndex)
    {
      m_administrativeActions.push_back(administrativeActionsJsonList[administrativeActionsIndex].AsObject());
    }
    m_administrativeActionsHasBeenSet = true;
  }

  return *this;
}

JsonValue Snapshot::Jsonize() const
{
  JsonValue payload;

  if(m_resourceARNHasBeenSet)
  {
   payload.WithString("ResourceARN", m_resourceARN);

  }

  if(m_snapshotIdHasBeenSet)
  {
   payload.WithString("SnapshotId", m_snapshotId);

  }

  if(m_nameHasBeenSet)
  {
   payload.WithString("Name", m_name);

  }

  if(m_volumeIdHasBeenSet)
  {
   payload.WithString("VolumeId", m_volumeId);

  }

  if(m_creationTimeHasBeenSet)
  {
   payload.WithDouble("CreationTime", m_creationTime.SecondsWithMSPrecision());
  }

  if(m_lifecycleHasBeenSet)
  {
   payload.WithString("Lifecycle", SnapshotLifecycleMapper::GetNameForSnapshotLifecycle(m_lifecycle));
  }

  if(m_lifecycleTransitionReasonHasBeenSet)
  {
   payload.WithObject("LifecycleTransitionReason", m_lifecycleTransitionReason.Jsonize());

  }

  if(m_tagsHasBeenSet)
  {
   Aws::Utils::Array<JsonValue> tagsJsonList(m_tags.size());
   for(unsigned tagsIndex = 0; tagsIndex < tagsJsonList.GetLength(); ++tagsIndex)
   {
     tagsJsonList[tagsIndex].AsObject(m_tags[tagsIndex].Jsonize());
   }
   payload.WithArray("Tags", std::move(tagsJsonList));

  }

  if(m_administrativeActionsHasBeenSet)
  {
   Aws::Utils::Array<JsonValue> administrativeActionsJsonList(m_administrativeActions.size());
   for(unsigned administrativeActionsIndex = 0; administrativeActionsIndex < administrativeActionsJsonList.GetLength(); ++administrativeActionsIndex)
   {
     administrativeActionsJsonList[administrativeActionsIndex].AsObject(m_administrativeActions[administrativeActionsIndex].Jsonize());
   }
   payload.WithArray("AdministrativeActions", std::move(administrativeActionsJsonList));

  }

  return payload;
}

} // namespace Model
} // namespace FSx
} // namespace Aws