Rename plugin from BIM to BCF

pull/6964/head
Wieland Lindenthal 6 years ago
parent a913099667
commit ce0840b18c
  1. 6
      Gemfile.lock
  2. 2
      Gemfile.modules
  3. 0
      modules/bcf/Gemfile
  4. 2
      modules/bcf/app/assets/stylesheets/bcf/bcf.sass
  5. 2
      modules/bcf/app/controllers/bcf/base_controller.rb
  6. 18
      modules/bcf/app/controllers/bcf/linked_issues_controller.rb
  7. 4
      modules/bcf/app/models/bcf.rb
  8. 6
      modules/bcf/app/models/bcf/comment.rb
  9. 2
      modules/bcf/app/models/bcf/initialize_with_uuid.rb
  10. 8
      modules/bcf/app/models/bcf/issue.rb
  11. 12
      modules/bcf/app/models/bcf/viewpoint.rb
  12. 10
      modules/bcf/app/views/bcf/linked_issues/import.html.erb
  13. 10
      modules/bcf/app/views/bcf/linked_issues/index.html.erb
  14. 10
      modules/bcf/app/views/bcf/linked_issues/prepare_import.html.erb
  15. 12
      modules/bcf/config/locales/en.yml
  16. 4
      modules/bcf/config/routes.rb
  17. 12
      modules/bcf/db/migrate/20181214103300_add_bcf_plugin.rb
  18. 6
      modules/bcf/lib/open_project/bcf.rb
  19. 2
      modules/bcf/lib/open_project/bcf/bcf_xml.rb
  20. 4
      modules/bcf/lib/open_project/bcf/bcf_xml/exporter.rb
  21. 2
      modules/bcf/lib/open_project/bcf/bcf_xml/file_entry.rb
  22. 2
      modules/bcf/lib/open_project/bcf/bcf_xml/importer.rb
  23. 6
      modules/bcf/lib/open_project/bcf/bcf_xml/issue_reader.rb
  24. 4
      modules/bcf/lib/open_project/bcf/bcf_xml/issue_writer.rb
  25. 2
      modules/bcf/lib/open_project/bcf/bcf_xml/markup_extractor.rb
  26. 30
      modules/bcf/lib/open_project/bcf/engine.rb
  27. 2
      modules/bcf/lib/open_project/bcf/patches/api/v3/export_formats.rb
  28. 4
      modules/bcf/lib/open_project/bcf/patches/work_package_patch.rb
  29. 2
      modules/bcf/lib/open_project/bcf/version.rb
  30. 1
      modules/bcf/lib/openproject-bcf.rb
  31. 10
      modules/bcf/openproject-bcf.gemspec
  32. 6
      modules/bim/lib/open_project/bim.rb
  33. 1
      modules/bim/lib/openproject-bim.rb

@ -125,9 +125,9 @@ PATH
openproject-pdf_export
PATH
remote: modules/bim
remote: modules/bcf
specs:
openproject-bim (9.0.0)
openproject-bcf (9.0.0)
activerecord-import
rails (~> 5)
rubyzip (~> 1.2)
@ -978,7 +978,7 @@ DEPENDENCIES
openproject-auth_saml!
openproject-avatars!
openproject-backlogs!
openproject-bim!
openproject-bcf!
openproject-boards!
openproject-costs!
openproject-documents!

@ -38,7 +38,7 @@ group :opf_plugins do
gem 'openproject-webhooks', path: 'modules/webhooks'
gem 'openproject-github_integration', path: 'modules/github_integration'
gem 'openproject-ldap_groups', path: 'modules/ldap_groups'
gem 'openproject-bim', path: 'modules/bim'
gem 'openproject-bcf', path: 'modules/bcf', require: !!(ENV['OPENPROJECT_EDITION'] == 'bim')
gem 'grids', path: 'modules/grids'
gem 'openproject-boards', path: 'modules/boards'

@ -1,4 +1,4 @@
.bim--bcf-issues
.bcf--issues
display: flex
flex-direction: row
flex-wrap: wrap

@ -1,4 +1,4 @@
module ::Bim
module ::Bcf
class BaseController < ApplicationController
end
end

@ -1,4 +1,4 @@
module ::Bim
module ::Bcf
class LinkedIssuesController < BaseController
include PaginationHelper
@ -13,10 +13,10 @@ module ::Bim
before_action :get_issue_type
menu_item :bim
menu_item :bcf
def index
@issues = BcfIssue.in_project(@project)
@issues = ::Bcf::Issue.in_project(@project)
.with_markup
.includes(:comments, :work_package, viewpoints: :attachments)
.page(page_param)
@ -30,12 +30,12 @@ module ::Bim
begin
@listing = @importer.get_extractor_list! @bcf_file.path
@issues = ::Bim::BcfIssue
@issues = ::Bcf::Issue
.with_markup
.includes(work_package: %i[status priority assigned_to])
.where(uuid: @listing.map { |e| e[:uuid] })
rescue StandardError => e
flash[:error] = I18n.t('bim.bcf.import_failed', error: e.message)
flash[:error] = I18n.t('bcf.bcf_xml.import_failed', error: e.message)
redirect_to action: :index
end
end
@ -43,9 +43,9 @@ module ::Bim
def perform_import
begin
result = @importer.import! @bcf_attachment.local_path
flash[:notice] = I18n.t('bim.bcf.import_successful', count: result)
flash[:notice] = I18n.t('bcf.bcf_xml.import_successful', count: result)
rescue StandardError => e
flash[:error] = I18n.t('bim.bcf.import_failed', error: e.message)
flash[:error] = I18n.t('bcf.bcf_xml.import_failed', error: e.message)
end
@bcf_attachment.destroy
@ -55,7 +55,7 @@ module ::Bim
private
def build_importer
@importer = ::OpenProject::Bim::BcfXml::Importer.new @project, current_user: current_user
@importer = ::OpenProject::Bcf::BcfXml::Importer.new @project, current_user: current_user
end
def get_issue_type
@ -80,7 +80,7 @@ module ::Bim
def check_file_param
path = params[:bcf_file]&.path
unless path && File.readable?(path)
flash[:error] = I18n.t('bim.bcf.import_failed', error: 'File missing or not readable')
flash[:error] = I18n.t('bcf.bcf_xml.import_failed', error: 'File missing or not readable')
redirect_to action: :import
end
end

@ -1,5 +1,5 @@
module Bim
module Bcf
def self.table_name_prefix
'bim_'
'bcf_'
end
end

@ -1,9 +1,9 @@
module Bim
class BcfComment < ActiveRecord::Base
module Bcf
class Comment < ActiveRecord::Base
include InitializeWithUuid
belongs_to :journal
belongs_to :issue, foreign_key: :issue_id, class_name: "Bim::BcfIssue"
belongs_to :issue, foreign_key: :issue_id, class_name: "Bcf::Issue"
validates_presence_of :uuid

@ -1,4 +1,4 @@
module Bim
module Bcf
##
# Module to set an initial UUID on the model

@ -1,5 +1,5 @@
module Bim
class BcfIssue < ActiveRecord::Base
module Bcf
class Issue < ActiveRecord::Base
include InitializeWithUuid
belongs_to :work_package
@ -27,7 +27,7 @@ module Bim
end
end
has_many :viewpoints, foreign_key: :issue_id, class_name: "Bim::BcfViewpoint"
has_many :comments, foreign_key: :issue_id, class_name: "Bim::BcfComment"
has_many :viewpoints, foreign_key: :issue_id, class_name: "Bcf::Viewpoint"
has_many :comments, foreign_key: :issue_id, class_name: "Bcf::Comment"
end
end

@ -1,17 +1,17 @@
module Bim
class BcfViewpoint < ActiveRecord::Base
module Bcf
class Viewpoint < ActiveRecord::Base
include InitializeWithUuid
acts_as_attachable view_permission: :view_linked_issues,
delete_permission: :manage_bim,
add_on_new_permission: :manage_bim,
add_on_persisted_permission: :manage_bim
delete_permission: :manage_bcf,
add_on_new_permission: :manage_bcf,
add_on_persisted_permission: :manage_bcf
def self.has_uuid?(uuid)
where(uuid: uuid).exists?
end
belongs_to :issue, foreign_key: :issue_id, class_name: "Bim::BcfIssue"
belongs_to :issue, foreign_key: :issue_id, class_name: "Bcf::Issue"
delegate :project, :project_id, to: :issue, allow_nil: true
def snapshot

@ -1,10 +1,10 @@
<%= toolbar title: t('bim.bcf.import') %>
<%= toolbar title: t('bcf.import') %>
<% unless @issue_type %>
<div class="notification-box -error">
<div class="notification-box--content">
<p>
<%= t('bim.bcf.type_not_active') %>
<%= t('bcf.bcf_xml.type_not_active') %>
<%= link_to t(:label_project_settings), settings_project_path(@project, tab: :types) %>
</p>
</div>
@ -14,16 +14,16 @@
<%= form_tag({ action: :prepare_import }, multipart: true, method: :post) do %>
<div class="form--field">
<%= styled_label_tag 'bcf_file', t('bim.bcf.xml_file') %>
<%= styled_label_tag 'bcf_file', t('bcf.bcf_xml.xml_file') %>
<div class="form--field-container">
<%= styled_file_field_tag :bcf_file, required: true %>
</div>
<div class="form--field-instructions">
<p><%= t('bim.import.description') %></p>
<p><%= t('bcf.bcf_xml.import.description') %></p>
</div>
</div>
<%= submit_tag t('bim.import.button_prepare'), class: 'button -highlight' %>
<%= submit_tag t('bcf.bcf_xml.import.button_prepare'), class: 'button -highlight' %>
<%= link_to t(:button_cancel),
{ action: :index },
class: 'button' %>

@ -1,7 +1,7 @@
<%= stylesheet_link_tag 'bim/bim.css' %>
<%= stylesheet_link_tag 'bcf/bcf.css' %>
<link rel="stylesheet" href="/highlighting/styles.css" />
<%= toolbar title: t('bim.linked_issues'), html: {class: '-with-dropdown'} do %>
<%= toolbar title: t('bcf.linked_issues'), html: {class: '-with-dropdown'} do %>
<li class="toolbar-item drop-down">
</li>
@ -17,17 +17,17 @@
<li class="toolbar-item">
<% query = { f: [filter_object('type', '=', @issue_type.id)] } %>
<%= link_to(project_work_packages_with_query_path(@project, query, format: :bcf),
title: t('bim.bcf.export'),
title: t('bcf.export'),
class: 'button export-bcf-button') do %>
<%= op_icon('button--icon icon-export') %>
<span class="button--text"><%= t('bim.bcf.export') %></span>
<span class="button--text"><%= t('bcf.export') %></span>
<% end %>
</li>
<% end %>
<% end %>
<% if @issues.present? %>
<div class="bim--bcf-issues">
<div class="bcf--issues">
<% @issues.each do |issue| %>
<% status_id = issue.work_package&.status_id %>
<% hl_classname = status_id.present? ? "__hl_row_status_#{status_id}" : '' %>

@ -1,7 +1,7 @@
<%= stylesheet_link_tag 'bim/bim.css' %>
<%= toolbar title: t('bim.bcf.import') %>
<%= stylesheet_link_tag 'bcf/bcf.css' %>
<%= toolbar title: t('bcf.import') %>
<p><%= t('bim.import.num_issues_found', x_bcf_issues: t('bim.x_bcf_issues', count: @listing.count)) %></p>
<p><%= t('bcf.import.num_issues_found', x_bcf_issues: t('bcf.x_bcf_issues', count: @listing.count)) %></p>
<% @listing.each do |entry| %>
<% issue = @issues.detect { |bcf| bcf.uuid == entry[:uuid] } %>
@ -52,8 +52,8 @@
<% end %>
<%= form_tag({ action: :perform_import }, multipart: true, method: :post) do %>
<p><%= t('bim.import.perform_description') %></p>
<%= submit_tag t('bim.import.button_perform_import'), class: 'button -highlight' %>
<p><%= t('bcf.import.perform_description') %></p>
<%= submit_tag t('bcf.import.button_perform_import'), class: 'button -highlight' %>
<%= link_to t(:button_cancel),
{ action: :index },
class: 'button' %>

@ -1,7 +1,7 @@
# English strings go here for Rails i18n
en:
bim:
label_bim: 'BIM'
bcf:
label_bcf: 'BCF'
linked_issues: "Linked issues"
x_bcf_issues:
@ -9,7 +9,7 @@ en:
one: 'One BCF issue'
other: '%{count} BCF issues'
bcf:
bcf_xml:
xml_file: 'BCF XML File'
import: 'Import from BCF'
export: 'Export all to BCF-XML'
@ -24,6 +24,6 @@ en:
button_perform_import: 'Confirm import'
description: "Provide a BCF-XML v2.1 file to import into this project. You can examine its contents before performing the import."
perform_description: "Do you want to import or update the issues listed above?"
export:
format:
bcf: "BCF-XML"
export:
format:
bcf: "BCF-XML"

@ -34,9 +34,9 @@
#++
OpenProject::Application.routes.draw do
scope '', as: 'bim' do
scope '', as: 'bcf' do
scope 'projects/:project_id', as: 'project' do
resources :linked_issues, controller: 'bim/linked_issues' do
resources :linked_issues, controller: 'bcf/linked_issues' do
get :import, action: :import, on: :collection
post :prepare_import, action: :prepare_import, on: :collection
post :import, action: :perform_import, on: :collection

@ -1,7 +1,7 @@
class AddBimPlugin < ActiveRecord::Migration[5.1]
class AddBcfPlugin < ActiveRecord::Migration[5.1]
def change
create_table :bim_bcf_issues do |t|
create_table :bcf_issues do |t|
t.text :uuid, index: true
t.column :markup, :xml
@ -9,24 +9,24 @@ class AddBimPlugin < ActiveRecord::Migration[5.1]
t.references :work_package, foreign_key: { on_delete: :cascade }, index: { unique: true }
end
create_table :bim_bcf_viewpoints do |t|
create_table :bcf_viewpoints do |t|
t.text :uuid, index: true
t.column :viewpoint, :xml
t.text :viewpoint_name
t.references :issue,
foreign_key: { to_table: :bim_bcf_issues, on_delete: :cascade }
foreign_key: { to_table: :bcf_issues, on_delete: :cascade }
# Create unique index on issue and uuid to avoid duplicates on resynchronization
t.index %i[uuid issue_id], unique: true
end
create_table :bim_bcf_comments do |t|
create_table :bcf_comments do |t|
t.text :uuid, index: true
t.references :journal, index: true
t.references :issue,
foreign_key: { to_table: :bim_bcf_issues, on_delete: :cascade },
foreign_key: { to_table: :bcf_issues, on_delete: :cascade },
index: true
# Create unique index on issue and uuid to avoid duplicates on resynchronization

@ -0,0 +1,6 @@
module OpenProject
module Bcf
require "open_project/bcf/engine"
require "open_project/bcf/bcf_xml"
end
end

@ -1,4 +1,4 @@
module OpenProject::Bim
module OpenProject::Bcf
module Bcf
require_relative './bcf_xml/importer'
end

@ -1,6 +1,6 @@
require 'fileutils'
module OpenProject::Bim::BcfXml
module OpenProject::Bcf::BcfXml
class Exporter < ::WorkPackage::Exporter::Base
include Redmine::I18n
@ -9,7 +9,7 @@ module OpenProject::Bim::BcfXml
end
def work_packages
super.includes(:journals, bim_bcf_issue: [:comments, { viewpoints: :attachments }])
super.includes(:journals, bcf_issue: [:comments, { viewpoints: :attachments }])
end
def list

@ -1,6 +1,6 @@
##
# Helper class to provide uploads from IO streams.
module OpenProject::Bim::BcfXml
module OpenProject::Bcf::BcfXml
class FileEntry < StringIO
def initialize(stream, filename:)

@ -1,7 +1,7 @@
require 'activerecord-import'
require_relative 'issue_reader'
module OpenProject::Bim::BcfXml
module OpenProject::Bcf::BcfXml
class Importer
attr_reader :project, :zip, :current_user

@ -4,7 +4,7 @@
# this should be turned into a representable/xml decorator
require_relative 'file_entry'
module OpenProject::Bim::BcfXml
module OpenProject::Bcf::BcfXml
class IssueReader
attr_reader :zip, :entry, :issue, :extractor, :project, :user, :type
@ -49,7 +49,7 @@ module OpenProject::Bim::BcfXml
if call.success?
wp = call.result
issue.work_package = wp
create_comment(user, I18n.t('bim.bcf.import_update_comment')) unless wp.previous_changes.empty?
create_comment(user, I18n.t('bcf.bcf_xml.import_update_comment')) unless wp.previous_changes.empty?
else
Rails.logger.error "Failed to synchronize BCF #{issue.uuid} with work package: #{call.errors.full_messages.join("; ")}"
end
@ -160,7 +160,7 @@ module OpenProject::Bim::BcfXml
##
# Find existing issue or create new
def find_or_initialize_issue
::Bim::BcfIssue.find_or_initialize_by(uuid: topic_uuid, project_id: project.id)
::Bcf::Issue.find_or_initialize_by(uuid: topic_uuid, project_id: project.id)
end
##

@ -1,6 +1,6 @@
##
# Creates or updates a BCF issue and markup from a work package
module OpenProject::Bim::BcfXml
module OpenProject::Bcf::BcfXml
class IssueWriter
attr_reader :work_package, :issue, :markup_doc, :markup_node
@ -162,7 +162,7 @@ module OpenProject::Bim::BcfXml
##
# Find existing issue or create new
def find_or_initialize_issue
::Bim::BcfIssue.find_or_initialize_by(work_package: work_package, project_id: work_package.project_id)
::Bcf::Issue.find_or_initialize_by(work_package: work_package, project_id: work_package.project_id)
end
def to_bcf_datetime(date_time)

@ -3,7 +3,7 @@
# manually. If we want to extract the entire markup,
# this should be turned into a representable/xml decorator
module OpenProject::Bim::BcfXml
module OpenProject::Bcf::BcfXml
class MarkupExtractor
attr_reader :entry, :markup, :doc

@ -1,35 +1,35 @@
require 'open_project/plugins'
module OpenProject::Bim
module OpenProject::Bcf
class Engine < ::Rails::Engine
engine_name :openproject_bim
engine_name :openproject_bcf
include OpenProject::Plugins::ActsAsOpEngine
register 'openproject-bim',
author_url: 'http://openproject.com',
register 'openproject-bcf',
author_url: 'https://openproject.com',
settings: {
default: {
}
} do
project_module :bim do
project_module :bcf do
permission :view_linked_issues,
'bim/linked_issues': :index
'bcf/linked_issues': :index
permission :manage_bim,
'bim/linked_issues': %i[index import prepare_import perform_import]
permission :manage_bcf,
'bcf/linked_issues': %i[index import prepare_import perform_import]
end
menu :project_menu,
:bim,
{ controller: '/bim/linked_issues', action: :index },
caption: :'bim.label_bim',
:bcf,
{ controller: '/bcf/linked_issues', action: :index },
caption: :'bcf.label_bcf',
param: :project_id,
icon: 'icon2 icon-backlogs'
end
assets %w(bim/bim.css)
assets %w(bcf/bcf.css)
patches %i[WorkPackage]
@ -39,18 +39,18 @@ module OpenProject::Bim
prepend Patches::Api::V3::ExportFormats
end
initializer 'bim.register_hooks' do
initializer 'bcf.register_hooks' do
# don't use require_dependency to not reload hooks in development mode
require 'open_project/xls_export/hooks/work_package_hook.rb'
end
initializer 'bim.register_mimetypes' do
initializer 'bcf.register_mimetypes' do
Mime::Type.register "application/octet-stream", :bcf unless Mime::Type.lookup_by_extension(:bcf)
end
config.to_prepare do
WorkPackage::Exporter
.register_for_list(:bcf, OpenProject::Bim::BcfXml::Exporter)
.register_for_list(:bcf, OpenProject::Bcf::BcfXml::Exporter)
end
end
end

@ -1,4 +1,4 @@
module OpenProject::Bim::Patches
module OpenProject::Bcf::Patches
module Api::V3::ExportFormats
def representation_formats
super + [representation_format_bcf]

@ -35,10 +35,10 @@
require_dependency 'work_package'
module OpenProject::Bim::Patches::WorkPackagePatch
module OpenProject::Bcf::Patches::WorkPackagePatch
def self.included(base)
base.class_eval do
has_one :bim_bcf_issue, class_name: 'Bim::BcfIssue', foreign_key: 'work_package_id'
has_one :bcf_issue, class_name: 'Bcf::Issue', foreign_key: 'work_package_id'
end
end
end

@ -1,7 +1,7 @@
require 'open_project/version'
module OpenProject
module Bim
module Bcf
VERSION = ::OpenProject::VERSION.to_semver
end
end

@ -0,0 +1 @@
require 'open_project/bcf'

@ -2,17 +2,17 @@
$:.push File.expand_path("../lib", __FILE__)
$:.push File.expand_path("../../lib", __dir__)
require "open_project/bim/version"
require "open_project/bcf/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "openproject-bim"
s.version = OpenProject::Bim::VERSION
s.name = "openproject-bcf"
s.version = OpenProject::Bcf::VERSION
s.authors = "OpenProject GmbH"
s.email = "info@openproject.com"
s.homepage = "https://community.openproject.org/"
s.summary = "OpenProject BIM authentication"
s.description = "This OpenProject plugin introduces BIM functionality"
s.summary = "OpenProject BCF import/export"
s.description = "This OpenProject plugin introduces BCF functionality"
s.files = Dir["{app,config,db,lib}/**/*", "CHANGELOG.md", "README.rdoc"]
s.test_files = Dir["spec/**/*"]

@ -1,6 +0,0 @@
module OpenProject
module Bim
require "open_project/bim/engine"
require "open_project/bim/bcf"
end
end

@ -1 +0,0 @@
require 'open_project/bim'
Loading…
Cancel
Save