コード例 #1
0
ファイル: EdiComposer.cpp プロジェクト: Skier/vault_repo
void EdiComposer::UpdateTrailer(const wxString& recordType)
{
    if ( recordType.Cmp(ADDED) == 0 ) {
        GetTrailer().TotalAdds++;
    } else if( recordType.Cmp(CHANGED) == 0 ) {
        GetTrailer().TotalChanges++;
    } else if( recordType.Cmp(MOVED) == 0 ) {
        GetTrailer().TotalMoveHistory++;
    } else if( recordType.Cmp(REPLACED) == 0 ) {
        GetTrailer().TotalReplacements++;
    }
};
コード例 #2
0
ファイル: EdiComposer.cpp プロジェクト: Skier/vault_repo
bool EdiComposer::ComposeTrailer()
{
    BufferClean();  

    BufferWriteRawData(GetTrailer().RecordType, 1);
    BufferWriteRawData(GetTrailer().Carrier, 9);
    wxString total;
    total << GetTrailer().TotalRecords;
    BufferWriteRawData(PrepareString(total, 9), 9);
    wxString added;
    added << GetTrailer().TotalAdds;
    BufferWriteRawData(PrepareString(added, 9), 9);
    wxString changed;
    changed << GetTrailer().TotalChanges;
    BufferWriteRawData(PrepareString(changed, 9), 9);
    wxString moved;
    moved << GetTrailer().TotalMoveHistory;
    BufferWriteRawData(PrepareString(moved, 9), 9);
    wxString rolled;
    BufferWriteRawData(PrepareString(rolled, 9), 9);
    wxString replaced;
    replaced << GetTrailer().TotalReplacements;
    BufferWriteRawData(PrepareString(replaced, 9), 9);

    BufferFlush();
    return true;
};
コード例 #3
0
ファイル: EdiComposer.cpp プロジェクト: Skier/vault_repo
// private
bool EdiComposer::ComposeHeader(const Document& doc) {

    bool result = true;

    BufferClean();
    for (size_t j=0; j<doc.GetDescriptor().GetSize(); j++) {

        WriteData(doc.GetField(j));
        if ( 0 == doc.GetField(j).GetDescriptor().GetName().Cmp(CARRIER_NAME) ) {
            SetCarrier(doc.GetField(j).GetValue());
            GetTrailer().Carrier = GetCarrier();
        }
    }
    BufferFlush();
    return result;
};
コード例 #4
0
ファイル: InternalComposer.cpp プロジェクト: Skier/vault_repo
bool InternalComposer::ComposeDetail(Descriptor* descriptor, Matrix* matrix)
{
    bool result = true;
    GetTrailer().TotalRecords = GetDetail()->GetNumberRows();
    size_t numberRows = GetDetail()->GetNumberRows();
    for (size_t i=0; i<numberRows; i++) {
        BufferClean();
        wxArrayString row;
        // prepare row
        for (size_t j=0, k=0; j<descriptor->GetSize(); j++) {
            XmlElementDescriptor* colDesc = (XmlElementDescriptor*)descriptor->GetElementDescriptor(j);
            if ( colDesc->IsEnabled() ) {
                row.Add(GetDetail()->GetValue(i, k++));
            } else {
                row.Add(colDesc->GetDefaultValue());
            }
        }
        // transformation for not enabled dependence
        for (size_t l=0; l<descriptor->GetSize(); l++) {
            XmlElementDescriptor* colDesc = (XmlElementDescriptor*)descriptor->GetElementDescriptor(l);
            ElementDependence* dep = colDesc->GetDependence();
            if ( NULL != dep ) {
                size_t index = dep->GetFieldIndex();
                if ( index >= 0 
                     && index < descriptor->GetSize()
                     && !descriptor->GetElementDescriptor(index)->IsEnabled() ) {
                    row[index] = colDesc->DependenceValue(row[l]);
                }
            }
        }
        // writing row to file
        wxString rowStr;
        for (size_t m=0; m<descriptor->GetSize(); m++) {
            ElementDescriptor* ed = GetDetail()->GetDescriptor()->GetElementDescriptor(m);
            bool dataCheck = CheckAndWriteData(ed, row[m]);
            if ( !dataCheck ) {
                LOG_MESSAGE(INFO_MESSAGE_LEVEL, wxString::Format(" Row is [%d].\n", i));
            }
            result = result && dataCheck;
        }
        UpdateTrailer(row[0]);
        BufferFlush();
    }
    return result;
};
コード例 #5
0
ファイル: EdiComposer.cpp プロジェクト: Skier/vault_repo
bool EdiComposer::ComposeDetail(const Document& doc) {
    bool result = true;

    GetTrailer().TotalRecords = doc.GetNumberRows();
    bool fillTrailer = true;

    for (size_t i=0; i<doc.GetNumberRows(); i++) {

        if ( fillTrailer )  {
            UpdateTrailer(doc.GetValue(i,0));
        }
        BufferClean();
        for (size_t j=0; j<doc.GetColCount(); j++) {
            WriteData(doc.GetColumnDescriptor(j), doc.GetValue(i,j));
        }
        BufferFlush();
    }
    return result;
};
コード例 #6
0
ファイル: InternalComposer.cpp プロジェクト: Skier/vault_repo
bool InternalComposer::ComposeHeader(Descriptor* descriptor, Matrix* matrix)
{
    bool result = true;
    BufferClean();
    for (int j=0; j<GetHeader()->GetSize(); j++) {
        bool dataCheck = CheckAndWriteData(
            GetHeader()->GetDescriptor()->GetElementDescriptor(j), 
            GetHeader()->GetField(j)->GetValue());
        if ( !dataCheck ) {
            LOG_MESSAGE(INFO_MESSAGE_LEVEL, wxString::Format(" Row is [%d].\n", 1));
        }
        if ( descriptor->GetElementDescriptor(j)->GetName().Cmp(CARRIER_NAME) == 0 ) {
            SetCarrier(GetHeader()->GetField(j)->GetValue());
            GetTrailer().Carrier = GetCarrier()->c_str();
        }
        result = result && dataCheck;
    }
    BufferFlush();
    return result;
};
コード例 #7
0
ファイル: EdiComposer.cpp プロジェクト: Skier/vault_repo
bool EdiComposer::Compose(const Document& doc, const wxString& outFilename) {

    m_outputFile = new wxFile(outFilename, wxFile::write);
    if ( !m_outputFile ) {
        LOG_ERROR(wxGetApp().GetLogger(), 0, ADVPCS_COMPOSE_ERROR_OPEN_EDI_FILE + outFilename + "]");
        return false;
    }

    BufferAlloc();
    GetTrailer().Reset();

    LOG_INFO(wxGetApp().GetLogger(), 0, ADVPCS_COMPOSE_BUILD_HEADER);
    bool hr = ComposeHeader(doc);

    LOG_INFO(wxGetApp().GetLogger(), 0, ADVPCS_COMPOSE_BUILD_DETAIL);
    bool dr = ComposeDetail(doc);

    LOG_INFO(wxGetApp().GetLogger(), 0, ADVPCS_COMPOSE_ADDING_TRAILER);
    ComposeTrailer(doc);

    BufferFree();
    LOG_INFO(wxGetApp().GetLogger(), 0, wxString::Format(ADVPCS_COMPOSE_OK, outFilename) );
    return hr & dr;
};
コード例 #8
0
ファイル: videometadata.cpp プロジェクト: StefanRoss/mythtv
void VideoMetadata::toMap(MetadataMap &metadataMap)
{
    if (this == NULL)
        return;

    QString coverfile;
    if (IsHostSet()
        && !GetCoverFile().startsWith("/")
        && !GetCoverFile().isEmpty()
        && !IsDefaultCoverFile(GetCoverFile()))
    {
        coverfile = generate_file_url("Coverart", GetHost(),
                GetCoverFile());
    }
    else
    {
        coverfile = GetCoverFile();
    }

    metadataMap["coverfile"] = coverfile;

    QString screenshotfile;
    if (IsHostSet() && !GetScreenshot().startsWith("/")
        && !GetScreenshot().isEmpty())
    {
        screenshotfile = generate_file_url("Screenshots",
                GetHost(), GetScreenshot());
    }
    else
    {
        screenshotfile = GetScreenshot();
    }

    metadataMap["screenshotfile"] = screenshotfile;

    QString bannerfile;
    if (IsHostSet() && !GetBanner().startsWith("/")
        && !GetBanner().isEmpty())
    {
        bannerfile = generate_file_url("Banners", GetHost(),
                GetBanner());
    }
    else
    {
        bannerfile = GetBanner();
    }

    metadataMap["bannerfile"] = bannerfile;

    QString fanartfile;
    if (IsHostSet() && !GetFanart().startsWith("/")
        && !GetFanart().isEmpty())
    {
        fanartfile = generate_file_url("Fanart", GetHost(),
                GetFanart());
    }
    else
    {
        fanartfile = GetFanart();
    }

    metadataMap["fanartfile"] = fanartfile;

    metadataMap["filename"] = GetFilename();
    metadataMap["title"] = GetTitle();
    metadataMap["subtitle"] = GetSubtitle();
    metadataMap["tagline"] = GetTagline();
    metadataMap["director"] = GetDirector();
    metadataMap["studio"] = GetStudio();
    metadataMap["description"] = GetPlot();
    metadataMap["genres"] = GetDisplayGenres(*this);
    metadataMap["countries"] = GetDisplayCountries(*this);
    metadataMap["cast"] = GetDisplayCast(*this).join(", ");
    metadataMap["rating"] = GetDisplayRating(GetRating());
    metadataMap["length"] = GetDisplayLength(GetLength());
    metadataMap["year"] = GetDisplayYear(GetYear());

    metadataMap["releasedate"] = MythDateToString(GetReleaseDate(), kDateFull);

    metadataMap["userrating"] = GetDisplayUserRating(GetUserRating());
    metadataMap["season"] = GetDisplaySeasonEpisode(GetSeason(), 1);
    metadataMap["episode"] = GetDisplaySeasonEpisode(GetEpisode(), 1);

    if (GetSeason() > 0 || GetEpisode() > 0)
    {
        metadataMap["s##e##"] = QString("s%1e%2").arg(GetDisplaySeasonEpisode
                                             (GetSeason(), 2))
                        .arg(GetDisplaySeasonEpisode(GetEpisode(), 2));
        metadataMap["##x##"] = QString("%1x%2").arg(GetDisplaySeasonEpisode
                                             (GetSeason(), 1))
                        .arg(GetDisplaySeasonEpisode(GetEpisode(), 2));
    }
    else
        metadataMap["s##e##"] = metadataMap["##x##"] = QString();

    metadataMap["trailerstate"] = TrailerToState(GetTrailer());
    metadataMap["userratingstate"] =
            QString::number((int)(GetUserRating()));
    metadataMap["watchedstate"] = WatchedToState(GetWatched());

    metadataMap["videolevel"] = ParentalLevelToState(GetShowLevel());

    metadataMap["insertdate"] = MythDateToString(GetInsertdate(), kDateFull);
    metadataMap["inetref"] = GetInetRef();
    metadataMap["homepage"] = GetHomepage();
    metadataMap["child_id"] = QString::number(GetChildID());
    metadataMap["browseable"] = GetDisplayBrowse(GetBrowse());
    metadataMap["watched"] = GetDisplayWatched(GetWatched());
    metadataMap["processed"] = GetDisplayProcessed(GetProcessed());
    metadataMap["category"] = GetCategory();
}