Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

zeitwerk compatible bim module

ulferts0e1f6a4b2d7c
diff --git a/modules/bcf/app/contracts/bcf/viewpoints/create_contract.rb b/modules/bcf/app/contracts/bcf/viewpoints/create_contract.rb
deleted file mode 100644
index 239aa26c82b..00000000000
--- a/modules/bcf/app/contracts/bcf/viewpoints/create_contract.rb
+++ /dev/null
@@ -1,274 +0,0 @@
-#-- encoding: UTF-8
-
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2020 the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2017 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program 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 2
-# of the License, or (at your option) any later version.
-#
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See docs/COPYRIGHT.rdoc for more details.
-#++
-
-module Bcf::Viewpoints
- class CreateContract < ::ModelContract
- include Bcf::ManageBcfGuarded
-
- WHITELISTED_PROPERTIES = %w(guid
- index
- snapshot
- orthogonal_camera
- perspective_camera
- clipping_planes
- bitmaps
- lines
- components).freeze
-
- ORTHOGONAL_CAMERA_PROPERTIES = %w(camera_view_point
- camera_direction
- camera_up_vector
- view_to_world_scale).freeze
-
- PERSPECTIVE_CAMERA_PROPERTIES = %w(camera_view_point
- camera_direction
- camera_up_vector
- field_of_view).freeze
-
- LINES_PROPERTIES = %w(start_point
- end_point).freeze
-
- CLIPPING_PLANES_PROPERTIES = %w(location
- direction).freeze
-
- COMPONENTS_PROPERTIES = %w(visibility
- selection
- coloring).freeze
-
- COMPONENT_PROPERTIES = %w(ifc_guid
- originating_system
- authoring_tool_id).freeze
-
- COLORING_PROPERTIES = %w(color
- components).freeze
-
- VISIBILITY_PROPERTIES = %w(default_visibility
- exceptions
- view_setup_hints).freeze
-
- VIEW_SETUP_HINTS_PROPERTIES = %w(spaces_visible
- space_boundaries_visible
- openings_visible).freeze
-
- COLOR_REGEXP = /#([0-9a-f]{2})?[0-9a-f]{6}/
-
- WHITELISTED_DIMENSIONS = %w(x y z).freeze
-
- attribute :uuid
- attribute :issue
- attribute :json_viewpoint do
- validate_json_viewpoint_present
- validate_json_viewpoint_hash
-
- next if errors.any?
-
- validate_properties
- validate_snapshot
- validate_index
- validate_orthogonal_camera
- validate_perspective_camera
- validate_lines
- validate_clipping_planes
- validate_bitmaps
- validate_components
- validate_guid
- end
-
- def validate_json_viewpoint_present
- errors.add(:json_viewpoint, :blank) unless viewpoint.present?
- end
-
- def validate_json_viewpoint_hash
- errors.add(:json_viewpoint, :no_json) if viewpoint.present? && !viewpoint.is_a?(Hash)
- end
-
- def validate_properties
- errors.add(:json_viewpoint, :unsupported_key) if viewpoint.present? && (viewpoint.keys - WHITELISTED_PROPERTIES).any?
- end
-
- def validate_snapshot
- return unless (sjson = viewpoint['snapshot'])
-
- errors.add(:json_viewpoint, :snapshot_type_unsupported) unless %w(jpg png).include? sjson['snapshot_type']
- errors.add(:json_viewpoint, :snapshot_data_blank) unless sjson['snapshot_data'].present?
- end
-
- def validate_index
- return unless (ijson = viewpoint['index'])
-
- errors.add(:json_viewpoint, :index_not_integer) unless ijson.is_a? Integer
- end
-
- def validate_orthogonal_camera
- return unless (ocjson = viewpoint['orthogonal_camera'])
-
- if ocjson.keys != ORTHOGONAL_CAMERA_PROPERTIES ||
- ocjson.except('view_to_world_scale').any? { |_, direction| invalid_direction?(direction) } ||
- !ocjson['view_to_world_scale'].is_a?(Numeric)
- errors.add(:json_viewpoint, :invalid_orthogonal_camera)
- end
- end
-
- def validate_perspective_camera
- return unless (pcjson = viewpoint['perspective_camera'])
-
- if pcjson.keys != PERSPECTIVE_CAMERA_PROPERTIES ||
- pcjson.except('field_of_view').any? { |_, direction| invalid_direction?(direction) } ||
- !pcjson['field_of_view'].is_a?(Numeric)
- errors.add(:json_viewpoint, :invalid_perspective_camera)
- end
- end
-
- def validate_lines
- return unless (ljson = viewpoint['lines'])
-
- if !ljson.is_a?(Array) ||
- ljson.any? { |line| invalid_line?(line) }
- errors.add(:json_viewpoint, :invalid_lines)
- end
- end
-
- def validate_clipping_planes
- return unless (cpjson = viewpoint['clipping_planes'])
-
- if !cpjson.is_a?(Array) ||
- cpjson.any? { |cp| invalid_clipping_plane?(cp) }
- errors.add(:json_viewpoint, :invalid_clipping_planes)
- end
- end
-
- def validate_bitmaps
- errors.add(:json_viewpoint, :bitmaps_not_writable) if viewpoint['bitmaps']
- end
-
- def validate_components
- return unless (cjson = viewpoint['components'])
-
- if !cjson.is_a?(Hash) ||
- invalid_components_properties?(cjson)
- errors.add(:json_viewpoint, :invalid_components)
- end
- end
-
- def validate_guid
- return unless (json_guid = viewpoint['guid'])
-
- errors.add(:json_viewpoint, :mismatching_guid) if json_guid != model.uuid
- end
-
- def invalid_components_properties?(json)
- (json.keys - COMPONENTS_PROPERTIES).any? ||
- invalid_visibility?(json['visibility']) ||
- invalid_components?(json['selection']) ||
- invalid_colorings?(json['coloring'])
- end
-
- def invalid_line?(line)
- invalid_hash_point?(line, LINES_PROPERTIES)
- end
-
- def invalid_clipping_plane?(line)
- invalid_hash_point?(line, CLIPPING_PLANES_PROPERTIES)
- end
-
- def invalid_hash_point?(hash, whitelist)
- !hash.is_a?(Hash) ||
- hash.keys != whitelist ||
- hash.values.any? { |v| invalid_point?(v) }
- end
-
- def invalid_visibility?(visibility)
- visibility.nil? ||
- !visibility.is_a?(Hash) ||
- (visibility.keys - VISIBILITY_PROPERTIES).any? ||
- invalid_default_visibility?(visibility['default_visibility']) ||
- invalid_components?(visibility['exceptions']) ||
- invalid_view_setup_hints?(visibility['view_setup_hints'])
- end
-
- def invalid_components?(components)
- return false unless components.present?
-
- !components.is_a?(Array) || components.any? { |component| invalid_component?(component) }
- end
-
- def invalid_colorings?(colorings)
- return false unless colorings.present?
-
- !colorings.is_a?(Array) || colorings.any? { |coloring| invalid_coloring?(coloring) }
- end
-
- def invalid_component?(component)
- !component.is_a?(Hash) ||
- component.empty? ||
- (component.keys - COMPONENT_PROPERTIES).any? ||
- component.values.any? { |v| !v.is_a?(String) }
- end
-
- def invalid_coloring?(coloring)
- !coloring.is_a?(Hash) ||
- coloring.keys != COLORING_PROPERTIES ||
- invalid_color?(coloring['color']) ||
- invalid_components?(coloring['components'])
- end
-
- def invalid_color?(color)
- !(color.is_a?(String) && color.match?(COLOR_REGEXP))
- end
-
- def invalid_direction?(direction)
- !direction.is_a?(Hash) ||
- direction.keys != WHITELISTED_DIMENSIONS ||
- direction.values.any? { |v| !v.is_a? Numeric }
- end
- alias_method :invalid_point?, :invalid_direction?
-
- def invalid_default_visibility?(visibility)
- visibility.present? &&
- no_boolean?(visibility)
- end
-
- def invalid_view_setup_hints?(hints)
- return false if hints.nil?
-
- !hints.is_a?(Hash) ||
- (hints.keys - VIEW_SETUP_HINTS_PROPERTIES).any? ||
- hints.values.any? { |v| no_boolean?(v) }
- end
-
- def no_boolean?(property)
- !(property.is_a?(TrueClass) || property.is_a?(FalseClass))
- end
-
- def viewpoint
- model.json_viewpoint
- end
- end
-end
diff --git a/modules/bcf/app/contracts/concerns/bcf/manage_bcf_guarded.rb b/modules/bcf/app/contracts/concerns/bcf/manage_bcf_guarded.rb
deleted file mode 100644
index b08db9d0bba..00000000000
--- a/modules/bcf/app/contracts/concerns/bcf/manage_bcf_guarded.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-#-- encoding: UTF-8
-
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2020 the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2017 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program 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 2
-# of the License, or (at your option) any later version.
-#
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See docs/COPYRIGHT.rdoc for more details.
-#++
-
-module Bcf
- module ManageBcfGuarded
- extend ActiveSupport::Concern
-
- included do
- def validate
- validate_user_allowed_to_manage
-
- super
- end
-
- private
-
- def validate_user_allowed_to_manage
- unless model.project && user.allowed_to?(:manage_bcf, model.project)
- errors.add :base, :error_unauthorized
- end
- end
- end
- end
-end
diff --git a/modules/bcf/config/locales/crowdin/bg.yml b/modules/bcf/config/locales/crowdin/bg.yml
deleted file mode 100644
index 75516958011..00000000000
--- a/modules/bcf/config/locales/crowdin/bg.yml
+++ /dev/null
@@ -1,84 +0,0 @@
-#English strings go here for Rails i18n
-bg:
- bcf:
- label_bcf: 'BCF'
- label_imported_failed: 'Failed imports of BCF topics'
- label_imported_successfully: 'Successfully imported BCF topics'
- issues: "Issues"
- recommended: 'recommended'
- not_recommended: 'not recommended'
- no_viewpoints: 'No viewpoints'
- new_badge: "Нов"
- exceptions:
- file_invalid: "BCF file invalid"
- x_bcf_issues:
- zero: 'Няма проблеми с BCF'
- one: 'One BCF issue'
- other: '%{count} BCF issues'
- bcf_xml:
- xml_file: 'BCF XML File'
- import_title: 'Import'
- export: 'Експортиране'
- import_update_comment: '(Updated in BCF import)'
- import_failed: 'Cannot import BCF file: %{error}'
- import_successful: 'Imported %{count} BCF issues'
- import_canceled: 'BCF-XML import canceled.'
- type_not_active: "The issue type is not activated for this project."
- import:
- num_issues_found: '%{x_bcf_issues} are contained in the BCF-XML file, their details are listed below.'
- button_prepare: 'Prepare import'
- button_perform_import: 'Confirm import'
- button_proceed: 'Proceed'
- button_back_to_list: 'Back to list'
- no_permission_to_add_members: 'You do not have sufficient permissions to add them as members to the project.'
- contact_project_admin: 'Contact your project admin to add them as members and start this import again.'
- continue_anyways: 'Do you want to proceed and finish the import anyways?'
- description: "Provide a BCF-XML v2.1 file to import into this project. You can examine its contents before performing the import."
- invalid_types_found: 'Invalid topic type names found'
- invalid_statuses_found: 'Invalid status names found'
- invalid_priorities_found: 'Invalid priority names found'
- invalid_emails_found: 'Invalid email addresses found'
- unknown_emails_found: 'Unknown email addresses found'
- unknown_property: 'Unknown property'
- non_members_found: 'Non project members found'
- import_types_as: 'Set all these types to'
- import_statuses_as: 'Set all these statuses to'
- import_priorities_as: 'Set all these priorities to'
- invite_as_members_with_role: 'Invite them as members to the project "%{project}" with role'
- add_as_members_with_role: 'Add them as members to the project "%{project}" with role'
- no_type_provided: 'No type provided'
- no_status_provided: 'No status provided'
- no_priority_provided: 'No priority provided'
- perform_description: "Do you want to import or update the issues listed above?"
- replace_with_system_user: 'Replace them with "System" user'
- import_as_system_user: 'Import them as "System" user.'
- what_to_do: "Какво искате да правите?"
- work_package_has_newer_changes: "Outdated! This topic was not updated as the latest changes on the server were newer than the \"ModifiedDate\" of the imported topic. However, comments to the topic were imported."
- export:
- format:
- bcf: "BCF-XML"
- attributes:
- bcf_thumbnail: "BCF snapshot"
- project_module_bcf: "BCF"
- permission_view_linked_issues: "View BCF issues"
- permission_manage_bcf: "Import and manage BCF issues"
- oauth:
- scopes:
- bcf_v2_1: "Full access to the BCF v2.1 API"
- bcf_v2_1_text: "Application will receive full read & write access to the OpenProject BCF API v2.1 to perform actions on your behalf."
- activerecord:
- errors:
- models:
- bcf/viewpoint:
- bitmaps_not_writable: "bitmaps is not writable as it is not yet implemented."
- index_not_integer: "index is not an integer."
- invalid_clipping_planes: "clipping_planes is invalid."
- invalid_components: "components is invalid."
- invalid_lines: "lines is invalid."
- invalid_orthogonal_camera: "orthogonal_camera is invalid."
- invalid_perspective_camera: "perspective_camera is invalid."
- mismatching_guid: "The guid in the json_viewpoint does not match the model's guid."
- no_json: "Is not a well structured json."
- snapshot_type_unsupported: "snapshot_type needs to be either 'png' or 'jpg'."
- snapshot_data_blank: "snapshot_data needs to be provided."
- unsupported_key: "An unsupported json property is included."
diff --git a/modules/bcf/config/locales/crowdin/js-bg.yml b/modules/bcf/config/locales/crowdin/js-bg.yml
deleted file mode 100644
index ce3b0286184..00000000000
--- a/modules/bcf/config/locales/crowdin/js-bg.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-#English strings go here
-bg:
- js:
- bcf:
- import: 'Import'
- export: 'Експортиране'
diff --git a/modules/bim/app/contracts/bim/bcf/work_packages/update_contract.rb b/modules/bim/app/contracts/bim/bcf/work_packages/update_contract.rb
index 23727408fa5..45619124542 100644
--- a/modules/bim/app/contracts/bim/bcf/work_packages/update_contract.rb
+++ b/modules/bim/app/contracts/bim/bcf/work_packages/update_contract.rb
@@ -31,7 +31,7 @@
# The contract allows for setting the default status ignoring status transitions.
# It is required so that put requests can set the status to the default status if the status property
# is omitted.
-module Bim::BcfWorkPackages
+module Bim::Bcf::WorkPackages
class UpdateContract < ::WorkPackages::UpdateContract
def self.model
::WorkPackage
diff --git a/modules/bim/app/representers/bim/bcf/api/v2_1/errors/error_representer.rb b/modules/bim/app/representers/bim/bcf/api/v2_1/errors/error_representer.rb
index a14853309ba..766f57923ca 100644
--- a/modules/bim/app/representers/bim/bcf/api/v2_1/errors/error_representer.rb
+++ b/modules/bim/app/representers/bim/bcf/api/v2_1/errors/error_representer.rb
@@ -29,7 +29,7 @@
#++
module Bim::Bcf::API::V2_1::Errors
- class ErrorRepresenter < BaseRepresenter
+ class ErrorRepresenter < Bim::Bcf::API::V2_1::BaseRepresenter
property :message,
getter: ->(*) {
[message].concat(Array(errors).map(&:message)).compact.join(' ')
diff --git a/modules/bim/lib/open_project/bim/engine.rb b/modules/bim/lib/open_project/bim/engine.rb
index 971b986dc0a..a3291b539b4 100644
--- a/modules/bim/lib/open_project/bim/engine.rb
+++ b/modules/bim/lib/open_project/bim/engine.rb
@@ -66,7 +66,7 @@ module OpenProject::Bim
::Redmine::MenuManager.map(:project_menu) do |menu|
menu.push(:ifc_models,
- {controller: '/bim/ifc_models/ifc_models', action: 'defaults'},
+ { controller: '/bim/ifc_models/ifc_models', action: 'defaults' },
caption: :'bim.label_bim',
param: :project_id,
after: :work_packages,
@@ -74,14 +74,15 @@ module OpenProject::Bim
badge: :label_new)
menu.push :ifc_viewer_panels,
- {controller: '/bim/ifc_models/ifc_models', action: 'defaults'},
+ { controller: '/bim/ifc_models/ifc_models', action: 'defaults' },
param: :project_id,
parent: :ifc_models,
partial: '/bim/ifc_models/ifc_models/panels'
end
-
end
+ class_inflection_override('v2_1' => 'V2_1')
+
assets %w(bim/bcf.css bim/ifc_viewer/generic.css)
patches %i[WorkPackage Type Journal RootSeeder Project]
@@ -119,7 +120,7 @@ module OpenProject::Bim
extend_api_response(:v3, :work_packages, :work_package_collection) do
require_relative 'patches/api/v3/export_formats'
- prepend Patches::Api::V3::ExportFormats
+ prepend Patches::API::V3::ExportFormats
end
extend_api_response(:v3, :work_packages, :schema, :work_package_schema) do
diff --git a/modules/bim/lib/open_project/bim/patches/api/v3/export_formats.rb b/modules/bim/lib/open_project/bim/patches/api/v3/export_formats.rb
index 533cceb30ad..408a8bd8cac 100644
--- a/modules/bim/lib/open_project/bim/patches/api/v3/export_formats.rb
+++ b/modules/bim/lib/open_project/bim/patches/api/v3/export_formats.rb
@@ -1,5 +1,5 @@
module OpenProject::Bim::Patches
- module Api::V3::ExportFormats
+ module API::V3::ExportFormats
def representation_formats
super + [representation_format_bcf]
end