Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion migrations/migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,5 @@ migrations:
- AddOnDeleteCascadeForEventsAndPresentationMaterials
- AddSummitCalendarSyncErrorEmailMigration
- RefactorDefaultEventTypesMigration

- PopulateComponentCategoriesMigration
- PopulateSubCategoriesAndTagsMigration
13 changes: 0 additions & 13 deletions openstack/code/CommunityPageBis.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,6 @@ function init()
Requirements::javascript('themes/openstack/javascript/community-bis.js');
}

function getProjectGroups() {
$groups = OpenStackComponent::$categories;
$list = new ArrayList();
foreach ($groups as $key => $group) {
$list->push(new ArrayData([
'Name' => $group,
'Key' => $key
]));
}

return $list;
}

function getComponentsByGroup($group) {
return OpenStackComponent::get()->filter('Use', $group);
}
Expand Down
3 changes: 3 additions & 0 deletions software/_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@


Object::add_extension('OpenStackComponent', 'OpenStackComponentAdminUI');
Object::add_extension('OpenStackComponentCategory', 'OpenStackComponentCategoryAdminUI');
Object::add_extension('OpenStackComponentSubCategory', 'OpenStackComponentSubCategoryAdminUI');
Object::add_extension('OpenStackComponentTag', 'OpenStackComponentTagAdminUI');
Object::add_extension('OpenStackApiVersion', 'OpenStackApiVersionAdminUI');
Object::add_extension('OpenStackRelease', 'OpenStackReleaseAdminUI');
Object::add_extension('OpenStackReleaseSupportedApiVersion', 'OpenStackReleaseSupportedApiVersionAdminUI');
Expand Down
67 changes: 40 additions & 27 deletions software/code/infrastructure/active_records/OpenStackComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,6 @@ class OpenStackComponent extends DataObject implements IOpenStackComponent

use SluggableEntity;

// IMPORTANT : this fixes the order for categories on software page
public static $categories = array(
"Compute",
"Storage, Backup & Recovery",
"Networking & Content Delivery",
"Data & Analytics",
"Security, Identity & Compliance",
"Management Tools",
"Deployment Tools",
"Application Services",
"None"
);

static $db = array
(
'Name' => 'Varchar(255)',
Expand All @@ -41,37 +28,38 @@ class OpenStackComponent extends DataObject implements IOpenStackComponent
'SupportsVersioning' => 'Boolean',
'SupportsExtensions' => 'Boolean',
'IsCoreService' => 'Boolean',
'Use' => 'Enum(array("Application Services","Compute","Data & Analytics","Deployment Tools","Management Tools","Monitoring & Metering","Networking & Content Delivery","Security, Identity & Compliance","Storage, Backup & Recovery","None"), "None")',
'HasStableBranches' => 'Boolean',
'WikiUrl' => 'Text',
'TCApprovedRelease' => 'Boolean',
'HasTeamDiversity' => 'Boolean',
'IncludedComputeStarterKit' => 'Boolean',
'VulnerabilityManaged' => 'Boolean',
'Order' => 'Int',
'YouTubeID' => 'Varchar',
'VideoDescription' => 'Text',
'VideoTitle' => 'Varchar',
'FollowsStandardDeprecation' => 'Boolean',
'SupportsUpgrade' => 'Boolean',
'SupportsRollingUpgrade' => 'Boolean',
'ShowOnMarketplace' => 'Boolean(1)',
'Slug' => 'Varchar(255)'
);

static $has_one = array
(
"LatestReleasePTL" => "Member",
"Mascot" => "Mascot"
"LatestReleasePTL" => "Member",
"Mascot" => "Mascot",
"SubCategory" => "OpenStackComponentSubCategory"
);

static $has_many = array
(
'Versions' => 'OpenStackApiVersion',
'RelatedContent' => 'OpenStackComponentRelatedContent',
'Caveats' => 'OpenStackComponentReleaseCaveat',
'Versions' => 'OpenStackApiVersion',
'RelatedContent' => 'OpenStackComponentRelatedContent',
'Caveats' => 'OpenStackComponentReleaseCaveat'
);

static $many_many = array
(
'Tags' => 'OpenStackComponentTag'
);

private static $many_many_extraFields = array
(
'Tags' => array( 'SortOrder' => 'Int' )
);

static $belongs_many_many = array
(
Expand Down Expand Up @@ -299,4 +287,29 @@ public function getCaveatsForReleaseType($release_id, $type)
)
);
}

/**
* @param IOpenStackComponentTag $new_tag
* @return void
*/
public function addTag(IOpenStackComponentTag $new_tag)
{
AssociationFactory::getInstance()->getMany2ManyAssociation($this, 'Tags')->add($new_tag);
}

/**
* @return IOpenStackComponentTag[]
*/
public function getMaturityTags()
{
return $this->Tags()->filter('Type', 'maturity');
}

/**
* @return IOpenStackComponentTag[]
*/
public function getInfoTags()
{
return $this->Tags()->filter('Type', 'info');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?php
/**
* Copyright 2017 Openstack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

/**
* Class OpenStackComponentCategory
*/
class OpenStackComponentCategory extends DataObject implements IOpenStackComponentCategory
{

static $db = array
(
'Name' => 'Varchar(255)',
'Description' => 'Text',
'Order' => 'Int'
);

static $many_many = array
(
'SubCategories' => 'OpenStackComponentSubCategory'
);

static $many_many_extraFields = array(
'SubCategories' => array(
'SubCatOrder' => 'Int'
)
);

/**
* @return int
*/
public function getIdentifier()
{
return (int)$this->getField('ID');
}

public function getName()
{
return $this->getField('Name');
}

public function setName($name)
{
$this->setField('Name', $name);
}

public function getDescription()
{
return $this->getField('Description');
}

public function setDescription($description)
{
$this->setField('Description', $description);
}

public function getOrder()
{
return $this->getField('Order');
}

public function setOrder($order)
{
$this->setField('Order', $order);
}

/**
* @return array
* @throws Exception
*/
public function getSubCategories()
{
return AssociationFactory::getInstance()->getMany2ManyAssociation($this, 'SubCategories')->toArray();
}

/**
* @param IOpenStackComponentSubCategory $new_sub_category
* @throws Exception
*/
public function addSubCategory(IOpenStackComponentSubCategory $new_sub_category)
{
AssociationFactory::getInstance()->getMany2ManyAssociation($this, 'SubCategories')->add($new_sub_category);
}

/**
* @param int $component_id
* @return bool
*/
public function hasOpenStackComponent($component_id)
{
foreach ($this->getSubCategories() as $subCategory) {
if ($subCategory->hasOpenStackComponent($component_id)) {
return true;
}
}

return false;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?php
/**
* Copyright 2017 Openstack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

/**
* Class OpenStackComponentSubCategory
*/
class OpenStackComponentSubCategory extends DataObject implements IOpenStackComponentSubCategory
{

static $db = array
(
'Name' => 'Varchar(255)',
'Description' => 'Text'
);

static $has_many = array
(
'OpenStackComponents' => 'OpenStackComponent'
);

static $belongs_many_many = array
(
'Categories' => 'OpenStackComponentCategory'
);

/**
* @return int
*/
public function getIdentifier()
{
return (int)$this->getField('ID');
}

public function getName()
{
return $this->getField('Name');
}

public function setName($name)
{
$this->setField('Name', $name);
}

public function getDescription()
{
return $this->getField('Description');
}

public function setDescription($description)
{
$this->setField('Description', $description);
}

public function getOrder()
{
return $this->getField('Order');
}

public function setOrder($order)
{
$this->setField('Order', $order);
}

/**
* @return array
* @throws Exception
*/
public function getOpenStackComponents()
{
return AssociationFactory::getInstance()->getOne2ManyAssociation($this, 'OpenStackComponents')->toArray();
}

/**
* @param IOpenStackComponent $new_component
* @throws Exception
*/
public function addOpenStackComponent(IOpenStackComponent $new_component)
{
AssociationFactory::getInstance()->getOne2ManyAssociation($this, 'OpenStackComponents')->add($new_component);
}

/**
* @param int $component_id
* @return bool
*/
public function hasOpenStackComponent($component_id)
{
foreach ($this->getOpenStackComponents() as $component) {
if ($component->getIdentifier() == $component_id) {
return true;
}
}

return false;
}

}
Loading