text:
Support, not judgement, for those making tough choices
Micaela Lara Cadena
As Catholics and people of faith, who are we if not our relationship with God? It's a complex, personal and sacred truth unique to each of us.
For my friend and colleague, New Mexico State Sen. Joseph Cervantes, that core truth was attacked last week when he was refused Holy Communion during a small Mass in the Mesilla Valley where we call home. Since speaking with Joseph, I'm still feeling the sting of what happened in deeply personal ways. Yet his concerns — and mine — have quickly shifted to the dangerous message this punitive decision sends to everyday New Mexicans and those across our nation.
Public scrutiny of elected officials is fair and valid. But what weighs heavy is that so many others are bearing witness to this moment. For those who may have felt like these actions labeled you a sinner or cast you from the light of our faith, you are not alone. I see you, and so many of us stand with you.
As a mama, Chicana and Catholic raised in this diocese, I know pregnancy is sacred, and that's exactly why I recognize that these decisions forever belong in the hearts of those holding these immense responsibilities. And while select voices within the church hierarchy may think they can dictate what's best for our families and chastise us if we fail to act according to their views, our faith also teaches us to care for our fellowship by caring for our communities.
As Sen. Cervantes recently shared regarding New Mexico's repeal of unconstitutional 1969 statutes that criminalized abortion, "I wanted to encourage values based on inclusivity, understanding, forgiveness and compassion, which are the core of Christ's teachings." I wholeheartedly agree.
The cultural war being waged by overreaching American bishops couldn't come at a worse time for women and pregnant people in our country.
Earlier this summer, Texas passed one of the most dangerous anti-abortion bills this country has ever seen, which goes into effect in a matter of weeks. In Washington D.C., the Supreme Court has announced it will hear a case that brings the basic protections of Roe v. Wade into question. This could eliminate or severely restrict access to abortion — even before a pregnancy is viable — in nearly half the states in our country.
New Mexico, however, will remain a place of solace, refuge and care, thanks to the courageous work of the Legislature, governor, Indigenous leaders and New Mexicans from across this state who organized to protect our access to safe and legal abortion. We've protected the long-standing access to health care that New Mexicans and others have relied on for decades, and firmly planted our state on the right side of history.
Advocating for the pregnancy-related care people may need over their lifetimes has been a significant part of my career. Through my experiences, I've learned that the overwhelming majority of Catholics and communities of faith agree, we can hold our own moral views about abortion and still trust a woman and her family to make these decisions themselves. I am called to this work because of my faith, not in spite of it.
Ultimately, when the end of my life is near, I hope to have lived every day practicing the tenets of the church and family of faith that raised me — forgiveness, compassion and love.
For today, I will pray for, hold close, and honor the women and families who've navigated their own complex pregnancies — whether they've suffered through miscarriages and losing little ones they wanted, worried about the immense weight of parenting and raising kids, or made their own decision to terminate a pregnancy. They are all New Mexicans who deserve our support, not our judgement.
State Rep. Micaela Lara Cadena, D-Mesilla, represents District 33.


Technology developed by two MIT alumni entrepreneurs is helping developers create smarter online music-streaming services.
If you ever use Spotify, or a similar music-streaming service, there's a good chance your song recommendations, and other personalized features, are powered by novel technology developed and marketed by two MIT alumni entrepreneurs.
Brian Whitman PhD '05 and Tristan Jehan SM '01, PhD '05 are co-founders of Echo Nest, whose technology — based on their MIT research — mines data from millions of songs streaming online. Sometimes called "the big data of music," the company has compiled about a trillion data points from 35 million songs by 2.5 million artists.
Its music-intelligence platform — recently praised in publications such as Fast Company, Wired and Business Insider, among others — then translates this data into information for music-app developers, who use the information to build smarter, more personalized music apps.
Now, as a leader in the music-intelligence industry, Echo Nest has dozens of big-name clients, including MTV, BBC, Rdio, VEVO, Foursquare, Nokia, Sirius XM, Clear Channel's iHeartRadio, Univision Radio and Intel.
The company also provides third-party developers with access to this data via an application programming interface (API) that has become the technological blueprint for more than 400 apps, including iHeartRadio and eMusic.
The co-founders say the company's success is due, in part, to technology that predicted the growth of today's booming online-music market — which ushered in a host of music-streaming sites and saw the growth of Internet radio. "When all that technology was rising around us, we were ready," Whitman says.
The foundations of Echo Nest's technology trace back to the MIT Media Lab, where the co-founders, then doctoral students, decided to combine their dissertations on music-data mining.
Jehan's dissertation, which he conducted in the Hyperinstruments Group, focused on the "content analysis" of music, extracting data on musical elements such as tempo, key and time signature. Whitman's work — conducted under the tutelage of professor emeritus Barry Vercoe — looked at a "cultural analysis" of music, focusing on what different types of people were saying about music online.
Most of the developer clients, for instance, use Echo Nest's data to better understand listeners' tastes and behaviors and create smarter music-streaming features, such as song recommendations, playlist generation, taste profiling, acoustic analysis, acoustic fingerprinting (an audio sample used to identify songs) and data feeds.
But an additional perk of Echo Nest's massive database, the co-founders say, is that it can help increase the visibility of rising Internet musicians who may have slipped through the song-recommendation cracks of earlier music-streaming services. For instance, MTV's music-streaming service is using it to help listeners discover artists who may be popular on the Web, but who don't get radio play.
"We're both musicians, and it's frustrating knowing that an independent artist may not get noticed in music-streaming sites. We wanted to change that," says Whitman, who recorded as an electronica musician before starting Echo Nest. Jehan is a keyboardist and guitar player who used to play in a Boston-based Brazilian band.
In the company's early days, the co-founders say they found support through MIT's Venture Mentoring Service (VMS) and the MIT Media Lab, which helped turn them from scientists to entrepreneurs.
Meeting regularly with business mentors such as Roman Lubynsky, VMS's senior venture advisor, the two learned the basics for growing a company and were introduced to a variety of contacts, including lawyers, accountants and investors. "It was a very connected culture," Jehan says.
Whitman agrees, adding that the MIT Media Lab helped with patents and other legal issues. The experience taught him how to pitch ideas to the business community — something that helped Echo Nest acquire its initial investors.
"As a scientist, being forced to explain your work to someone who's not a scientist was a valuable lesson," Whitman says.
As scientists who freely accessed data for their dissertations, Whitman and Jehan have made sure to pay it forward, making some of Echo Nest's data and technologies readily available for research purposes. In 2011, the company released a million-song dataset to academic institutions and released Echoprint, an open source music-identification system.


(*.doc or *.docx) and via the online submission system. Abstracts must be received no later than 15 December 2011. Abstracts submitted after the closing date will not be considered.
All abstracts must be original work. An abstract should not be submitted if the work is to be published/presented at a major national or international meeting prior to the Conference.
Splitting of a body of work into multiple abstracts is not allowed. Please submit your abstract only once!
Abstracts should be clear, concise, and written in English. The English must be well written and should be checked by someone well versed in English writing.
Submissions must be accompanied by an 80 word biographical paragraph of the presenting author. This information will be used by the Session Chair for introduction purposes or may also be published in Conference literature.
Do not use figures, tables or graphs in the abstracts. All data must be in narrative form.
All abstracts must be typed in Times New Roman 10pt font, left and right justified, single spaced.


Lagos (INVESTADVOCATE)-Insurer, Niger Insurance Plc said its pretax profit for the epriod ended December 31, 2016 declined 86.5 percent to N99 million from N736 million recorded a year ago.
Post-tax profit for the also dipped 93 percent to N42 million from N600 million reported the same period of 2015.
While gross premium income fell from N10.6 billion in 2015 end to N5.1 billion in the review period of 2016; indicating a drop of 53 percent.


text:
package com.khartec.waltz.data.survey;

import com.khartec.waltz.common.DateTimeUtilities;
import com.khartec.waltz.data.InlineSelectFieldFactory;
import com.khartec.waltz.model.EntityKind;
import com.khartec.waltz.model.EntityReference;
import com.khartec.waltz.model.survey.ImmutableSurveyInstanceQuestionResponse;
import com.khartec.waltz.model.survey.ImmutableSurveyQuestionResponse;
import com.khartec.waltz.model.survey.SurveyInstanceQuestionResponse;
import com.khartec.waltz.model.survey.SurveyQuestionResponse;
import com.khartec.waltz.schema.Tables;
import com.khartec.waltz.schema.tables.records.SurveyQuestionListResponseRecord;
import com.khartec.waltz.schema.tables.records.SurveyQuestionResponseRecord;
import org.jooq.*;
import org.jooq.impl.DSL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;

import static com.khartec.waltz.common.Checks.checkNotNull;
import static com.khartec.waltz.common.Checks.checkTrue;
import static com.khartec.waltz.common.CollectionUtilities.first;
import static com.khartec.waltz.common.ListUtilities.newArrayList;
import static com.khartec.waltz.common.SetUtilities.map;
import static com.khartec.waltz.common.StringUtilities.ifEmpty;
import static com.khartec.waltz.common.StringUtilities.join;
import static com.khartec.waltz.model.EntityReference.mkRef;
import static com.khartec.waltz.schema.Tables.SURVEY_INSTANCE;
import static com.khartec.waltz.schema.Tables.SURVEY_QUESTION_LIST_RESPONSE;
import static com.khartec.waltz.schema.tables.SurveyQuestionResponse.SURVEY_QUESTION_RESPONSE;
import static java.util.Optional.ofNullable;
import static java.util.stream.Collectors.*;
import static org.jooq.lambda.tuple.Tuple.tuple;

@Repository
public class SurveyQuestionResponseDao {

    private static final Field<String> entityNameField = InlineSelectFieldFactory.mkNameField(
            SURVEY_QUESTION_RESPONSE.ENTITY_RESPONSE_ID,
            SURVEY_QUESTION_RESPONSE.ENTITY_RESPONSE_KIND,
            newArrayList(EntityKind.APPLICATION, EntityKind.PERSON));

    private static final RecordMapper<Record, SurveyInstanceQuestionResponse> TO_DOMAIN_MAPPER = r -> {
        SurveyQuestionResponseRecord record = r.into(SURVEY_QUESTION_RESPONSE);

        Optional<EntityReference> entityReference = Optional.empty();
        if(record.getEntityResponseId() != null && record.getEntityResponseKind() != null) {
            entityReference = Optional.of(mkRef(
                    EntityKind.valueOf(record.getEntityResponseKind()),
                    record.getEntityResponseId(),
                    r.getValue(entityNameField)));
        }

        return ImmutableSurveyInstanceQuestionResponse.builder()
                .surveyInstanceId(record.getSurveyInstanceId())
                .personId(record.getPersonId())
                .lastUpdatedAt(record.getLastUpdatedAt().toLocalDateTime())
                .questionResponse(ImmutableSurveyQuestionResponse.builder()
                        .questionId(record.getQuestionId())
                        .comment(ofNullable(record.getComment()))
                        .stringResponse(ofNullable(record.getStringResponse()))
                        .numberResponse(ofNullable(record.getNumberResponse()).map(BigDecimal::doubleValue))
                        .booleanResponse(ofNullable(record.getBooleanResponse()))
                        .dateResponse(ofNullable(record.getDateResponse()).map(Date::toLocalDate))
                        .entityResponse(entityReference)
                        .build())
                .build();
    };

    private final DSLContext dsl;

    @Autowired
    public SurveyQuestionResponseDao(DSLContext dsl) {
        checkNotNull(dsl, "dsl cannot be null");

        this.dsl = dsl;
    }

    public List<SurveyInstanceQuestionResponse> findForInstance(long surveyInstanceId) {
        // fetch list responses
        List<SurveyQuestionListResponseRecord> listResponses = dsl
                .selectFrom(SURVEY_QUESTION_LIST_RESPONSE)
                .where(SURVEY_QUESTION_LIST_RESPONSE.SURVEY_INSTANCE_ID.eq(surveyInstanceId))
                .orderBy(SURVEY_QUESTION_LIST_RESPONSE.POSITION)
                .fetch();

        Map<Long, List<EntityReference>> entityListResponsesByQuestionId = listResponses
                .stream()
                .filter(d -> d.getEntityKind() != null)
                .map(d -> tuple(d.getQuestionId(), mkRef(
                        EntityKind.valueOf(d.getEntityKind()),
                        d.getEntityId(),
                        d.getResponse())))
                .collect(groupingBy(d -> d.v1, mapping(t -> t.v2, toList())));

        Map<Long, List<String>> stringListResponsesByQuestionId = listResponses
                .stream()
                .filter(d -> d.getEntityKind() == null)
                .map(d -> tuple(d.getQuestionId(),d.getResponse()))
                .collect(groupingBy(
                        d -> d.v1,
                        mapping(t -> t.v2, toList())));

        // fetch responses
        List<SurveyInstanceQuestionResponse> responses = dsl
                .select(SURVEY_QUESTION_RESPONSE.fields())
                .select(entityNameField)
                .from(SURVEY_QUESTION_RESPONSE)
                .where(SURVEY_QUESTION_RESPONSE.SURVEY_INSTANCE_ID.eq(surveyInstanceId))
                .fetch(TO_DOMAIN_MAPPER);

        return responses
                .stream()
                .map(r -> ImmutableSurveyInstanceQuestionResponse
                        .copyOf(r)
                        .withQuestionResponse(ImmutableSurveyQuestionResponse.copyOf(r.questionResponse())
                        .withListResponse(ofNullable(stringListResponsesByQuestionId.get(r.questionResponse().questionId())))
                        .withEntityListResponse(ofNullable(entityListResponsesByQuestionId.get(r.questionResponse().questionId())))))
                .collect(toList());
    }

    public int deletePreviousResponse(List<SurveyInstanceQuestionResponse> previousResponses) {
        checkNotNull(previousResponses, "responses cannot be null");
        if (!previousResponses.isEmpty()) {
            Set<Long> instanceIds = map(
                    previousResponses,
                    SurveyInstanceQuestionResponse::surveyInstanceId);

            checkTrue(instanceIds.size() == 1, "All responses must for the same surveyInstance");
            final Long instanceId = first(previousResponses).surveyInstanceId();

            final Set<Long> previousResponseIds = map(
                    previousResponses,
                    qr -> qr.questionResponse().questionId());

            int rmSingleCount = dsl
                    .deleteFrom(Tables.SURVEY_QUESTION_RESPONSE)
                    .where(SURVEY_QUESTION_RESPONSE.SURVEY_INSTANCE_ID.eq(instanceId))
                    .and(SURVEY_QUESTION_RESPONSE.QUESTION_ID.in(previousResponseIds))
                    .execute();

            int rmListCount = dsl
                    .deleteFrom(SURVEY_QUESTION_LIST_RESPONSE)
                    .where(SURVEY_QUESTION_LIST_RESPONSE.SURVEY_INSTANCE_ID.eq(instanceId))
                    .and(SURVEY_QUESTION_LIST_RESPONSE.QUESTION_ID.in(previousResponseIds))
                    .execute();

            return rmSingleCount + rmListCount;
        } else {
            return 0;
        }
    }

    public void saveResponse(SurveyInstanceQuestionResponse response) {
        checkNotNull(response, "response cannot be null");
        checkNotNull(response.questionResponse(), "response.questionResponse() cannot be null");

        SurveyQuestionResponseRecord record = mkRecord(response);

        Condition responseExistsCondition = DSL
                .exists(DSL
                    .selectFrom(SURVEY_QUESTION_RESPONSE)
                    .where(SURVEY_QUESTION_RESPONSE.SURVEY_INSTANCE_ID.eq(response.surveyInstanceId())
                        .and(SURVEY_QUESTION_RESPONSE.QUESTION_ID.eq(response.questionResponse().questionId()))));

        // save survey_question_response record
        Boolean responseExists = dsl
                .select(DSL
                        .when(responseExistsCondition, true)
                        .otherwise(false))
                .fetchOne(Record1::value1);

        dsl.transaction(configuration -> {
            DSLContext txDsl = DSL.using(configuration);

            if (responseExists) {
                txDsl.executeUpdate(record);
            } else {
                txDsl.executeInsert(record);
            }

            response.questionResponse()
                    .listResponse()
                    .ifPresent(list -> saveListResponse(
                            txDsl,
                            response.surveyInstanceId(),
                            response.questionResponse().questionId(),
                            list));

            response.questionResponse()
                    .entityListResponse()
                    .ifPresent(list -> saveEntityListResponse(
                            txDsl,
                            response.surveyInstanceId(),
                            response.questionResponse().questionId(),
                            list));
        });
    }

    private <T> void saveGenericListResponse(DSLContext txDsl,
                                             Long instanceId,
                                             Long questionId,
                                             List<T> list,
                                             BiConsumer<T, SurveyQuestionListResponseRecord> recordUpdater) {
        txDsl.deleteFrom(SURVEY_QUESTION_LIST_RESPONSE)
                .where(SURVEY_QUESTION_LIST_RESPONSE.SURVEY_INSTANCE_ID.eq(instanceId))
                .and(SURVEY_QUESTION_LIST_RESPONSE.QUESTION_ID.eq(questionId))
                .execute();

        if (! list.isEmpty()) {
            AtomicInteger counter = new AtomicInteger(0);
            List<SurveyQuestionListResponseRecord> listResponses = list
                    .stream()
                    .map(lr -> {
                        SurveyQuestionListResponseRecord rec = new SurveyQuestionListResponseRecord();
                        rec.setSurveyInstanceId(instanceId);
                        rec.setQuestionId(questionId);
                        rec.setPosition(counter.incrementAndGet());

                        recordUpdater.accept(lr, rec);

                        return rec;
                    })
                    .collect(toList());

            txDsl.batchInsert(listResponses)
                    .execute();
        }
    }

    private void saveListResponse(DSLContext txDsl,
                                  Long instanceId,
                                  Long questionId,
                                  List<String> list) {
        saveGenericListResponse(
                txDsl,
                instanceId,
                questionId,
                list,
                (listItem, record) -> record.setResponse(listItem));
    }

    private void saveEntityListResponse(DSLContext txDsl,
                                  Long instanceId,
                                  Long questionId,
                                  List<EntityReference> list) {
        saveGenericListResponse(
                txDsl,
                instanceId,
                questionId,
                list,
                (ref, record) -> {
                    record.setResponse(ref.name().orElse("?"));
                    record.setEntityId(ref.id());
                    record.setEntityKind(ref.kind().name());
                });
    }

    public void cloneResponses(long sourceSurveyInstanceId, long targetSurveyInstanceId) {
        List<SurveyQuestionResponseRecord> responseRecords = dsl
                .select(SURVEY_QUESTION_RESPONSE.fields())
                .select(entityNameField)
                .from(SURVEY_QUESTION_RESPONSE)
                .where(SURVEY_QUESTION_RESPONSE.SURVEY_INSTANCE_ID.eq(sourceSurveyInstanceId))
                .fetchInto(SURVEY_QUESTION_RESPONSE)
                .stream()
                .map(r -> {
                    r.setSurveyInstanceId(targetSurveyInstanceId);
                    r.changed(true);
                    return r;
                })
                .collect(toList());

        List<SurveyQuestionListResponseRecord> listResponseRecords = dsl
                .selectFrom(SURVEY_QUESTION_LIST_RESPONSE)
                .where(SURVEY_QUESTION_LIST_RESPONSE.SURVEY_INSTANCE_ID.eq(sourceSurveyInstanceId))
                .fetchInto(SURVEY_QUESTION_LIST_RESPONSE)
                .stream()
                .map(r -> {
                    r.setSurveyInstanceId(targetSurveyInstanceId);
                    r.changed(true);
                    return r;
                })
                .collect(toList());

        dsl.transaction(configuration -> {
            DSLContext txDsl = DSL.using(configuration);

            txDsl.batchInsert(responseRecords)
                    .execute();

            txDsl.batchInsert(listResponseRecords)
                    .execute();
        });
    }

    public int deleteForSurveyRun(long surveyRunId) {
        Select<Record1<Long>> surveyInstanceIdSelector = dsl.select(SURVEY_INSTANCE.ID)
                .from(SURVEY_INSTANCE)
                .where(SURVEY_INSTANCE.SURVEY_RUN_ID.eq(surveyRunId));

        // this will also auto delete any survey_question_list_response records (fk delete cascade)
        return dsl.delete(SURVEY_QUESTION_RESPONSE)
                .where(SURVEY_QUESTION_RESPONSE.SURVEY_INSTANCE_ID.in(surveyInstanceIdSelector))
                .execute();
    }

    private SurveyQuestionResponseRecord mkRecord(SurveyInstanceQuestionResponse response) {
        SurveyQuestionResponse questionResponse = response.questionResponse();
        Optional<EntityReference> entityResponse = questionResponse.entityResponse();

        SurveyQuestionResponseRecord record = dsl.newRecord(SURVEY_QUESTION_RESPONSE);
        record.setSurveyInstanceId(response.surveyInstanceId());
        record.setQuestionId(questionResponse.questionId());
        record.setPersonId(response.personId());
        record.setLastUpdatedAt(Timestamp.valueOf(response.lastUpdatedAt()));
        record.setComment(questionResponse.comment()
                            .map(c -> ifEmpty(c, null))
                            .orElse(null));
        record.setStringResponse(questionResponse.stringResponse()
                                    .map(s -> ifEmpty(s, null))
                                    .orElse(null));
        record.setNumberResponse(questionResponse.numberResponse()
                                    .map(BigDecimal::valueOf)
                                    .orElse(null));
        record.setBooleanResponse(questionResponse.booleanResponse().orElse(null));
        record.setDateResponse(questionResponse.dateResponse()
                                    .map(DateTimeUtilities::toSqlDate)
                                    .orElse(null));
        record.setEntityResponseKind(entityResponse.map(er -> er.kind().name()).orElse(null));
        record.setEntityResponseId(entityResponse.map(EntityReference::id).orElse(null));
        record.setListResponseConcat(questionResponse.listResponse()
                                        .filter(l -> ! l.isEmpty())
                                        .map(l -> join(l, "; "))
                                        .orElse(null));

        return record;
    }
}

redpajama_set_name: RedPajamaGithub