Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* This file is part of Port@l
* Port@l 3.0 - Portal Engine and Management System
* Copyright (C) 2010 Isotrol, SA. http://www.isotrol.com
*
* Port@l is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Port@l is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Port@l. If not, see .
*/
package com.isotrol.impe3.idx.d6;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import nu.xom.Attribute;
import nu.xom.Document;
import nu.xom.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcDaoSupport;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.springframework.transaction.annotation.Transactional;
import com.google.common.collect.ImmutableMap;
import com.isotrol.impe3.idx.LocalMappingsService;
import com.isotrol.impe3.idx.d6.Drupal6Content.Drupal6ContentBuilder;
/**
* Drupal6 Database Reader Implementation
* @author Alejandro Espinosa
* @author Javier Ráez
*/
public class Drupal6DatabaseReaderImpl extends NamedParameterJdbcDaoSupport implements Drupal6DatabaseReader {
private final Logger logger = LoggerFactory.getLogger(getClass());
private static final String ID = "id";
private static final String rutaThumbnails = "imagefield_thumbs";
private String selectContent;
private String selectFieldsNoTable;
private String selectValuesType1;
private String selectValuesType2;
private String selectValuesFile;
private String selectValuesNoTable1;
private String selectValuesNoTable2;
private String selectValuesVocabulary;
private String selectValuesParent;
private String selectTaxName;
private String selectLinkType;
private String selectUploadFiles;
private LocalMappingsService mappingsService;
/**
* @see org.springframework.dao.support.DaoSupport#initDao()
*/
@Override
protected void initDao() throws Exception {
this.logger.info("Init Drupal 6 database reader.");
selectContent = "select NID, VID, TYPE, LANGUAGE, TITLE, UID, STATUS,"
+ "CREATED, CHANGED, COMMENT, PROMOTE, MODERATE, STICKY, TNID, TRANSLATE from node where NID = :id";
selectFieldsNoTable = "SELECT f.field_name, f.type, f.multiple, f.module FROM content_node_field_instance i, "
+ "content_node_field f where i.type_name= :tipo and i.field_name=f.field_name and f.active='1' and locked='0'"
+ " and f.db_storage='0'";
selectValuesType1 = "SELECT * FROM content_type_";
selectValuesType2 = " where nid= :id";
selectValuesFile = "SELECT filepath from files where fid= :fid";
selectValuesNoTable1 = "SELECT * FROM content_";
selectValuesNoTable2 = " where nid=:nid";
selectValuesVocabulary = "select tid from term_node where nid= :id";
selectValuesParent = "select parent from term_hierarchy where tid= :tid";
selectTaxName = "select name from term_data where tid= :tid";
// FIXME
/*
* El campo field_texto_enlace_value, depende del nombre que se le de a el campo en drupal.
* Si se cambiara el nombre del campo seria necesario cambiar este valor
*/
selectLinkType = "SELECT nid, field_nodo_nid, field_texto_enlace_value " +
"FROM content_type_enlace_contenido where nid= :id";
selectUploadFiles = "select fid,weight,description from upload where nid= :id";
super.initDao();
}
private static final ParameterizedRowMapper CONTENT_MAPPER =
new ParameterizedRowMapper() {
public Drupal6ContentBuilder mapRow(ResultSet rs, int rowNum) throws SQLException {
Drupal6ContentBuilder builder = Drupal6Content.builder();
// NID,TYPE,STATUS,CREATED,CHANGED,LANGUAGE,TITLE,UID, , COMMENT, PROMOTE, MODERATE, STICKY, TNID,
// TRANSLATE,VID
int i = 1;
builder.setNid(rs.getInt(i++));
builder.setVid(rs.getInt(i++));
builder.setType(rs.getString(i++));
builder.setLanguage(rs.getString(i++));
builder.setTitle(rs.getString(i++));
builder.setUid(rs.getInt(i++));
builder.setStatus(rs.getInt(i++));
builder.setCreated(new Date(rs.getLong(i++)));
builder.setChanged(new Date(rs.getLong(i++)));
builder.setComment(rs.getInt(i++));
builder.setPromote(rs.getInt(i++));
builder.setModerate(rs.getInt(i++));
builder.setSticky(rs.getInt(i++));
builder.setTnid(rs.getInt(i++));
builder.setTranslate(rs.getInt(i++));
return builder;
}
};
static class TextFieldRowMapper implements org.springframework.jdbc.core.RowMapper {
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
Map contenido = new HashMap();
int i = 1;
contenido.put(rs.getString(i++), rs.getString(i++));
return contenido;
}
}
/**
*
* @see com.isotrol.impe3.idx.d6.Drupal6DatabaseReader#createBuilder(java.lang.String)
*/
@Transactional
public Drupal6ContentBuilder createBuilder(String id) {
Drupal6ContentBuilder builder = (Drupal6ContentBuilder) getNamedParameterJdbcTemplate().queryForObject(
selectContent, ImmutableMap.of(ID, id), CONTENT_MAPPER);
readContentFields(builder);
return builder;
}
@Transactional
public void readContentFields(Drupal6ContentBuilder builder) {
final Map mapa = new HashMap();
List