Skip to content

Commit

Permalink
Merge pull request #905 from linea-it/develop
Browse files Browse the repository at this point in the history
v0.15
  • Loading branch information
glaubervila authored Nov 28, 2017
2 parents 518ec68 + e93123b commit a7b07b6
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 36 deletions.
2 changes: 1 addition & 1 deletion api/product_classifier/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ProductClassViewSet(viewsets.ModelViewSet):

search_fields = ('pcl_name', 'pcl_display_name')

filter_fields = ('id', 'pcl_name', 'pcl_display_name',)
filter_fields = ('id', 'pcl_name', 'pcl_display_name', 'pcl_group')

ordering_fields = ('id', 'pcl_name', 'pcl_display_name')

Expand Down
57 changes: 52 additions & 5 deletions api/product_register/ImportProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from common.models import Filter
from django.db.models import Q
from lib.CatalogDB import CatalogDB
from product.models import Catalog, Map, Mask, ProductContent, ProductRelease, ProductTag, ProductContentAssociation
from product.models import Catalog, Map, Mask, ProductContent, ProductRelease, ProductTag, ProductContentAssociation, \
ProductRelated
from product_classifier.models import ProductClass, ProductClassContent
from product_register.models import ProcessRelease
from rest_framework import status
Expand All @@ -25,6 +26,13 @@ def start_import(self, request):
'request': request
}

# Esta propriedade e usada apenas se no mesmo processo tiver 2 produtos um de Galaxy Cluster e um de Cluster Member
# dict({
# 'galaxy_clusters': ProductModel
# 'cluster_memebers': ProductModel
# })
self._gc_cm = dict({})

# Ticket server para identificar o owner do processo quando
# o processo esta sendo importado por outro sistema, nesse caso o user logado
# sera o sistema externo autenticado pelo token, e o owner sera recuperado pelo ticket.
Expand Down Expand Up @@ -183,6 +191,10 @@ def import_products(self, data):
else:
raise Exception("Product Type '%s' not implemented yet." % product.get('type'))

# Verificar a classe dos produtos se for galaxy cluster ou cluster members deve ser feita a ligacao entre as 2
if ('galaxy_clusters' in self._gc_cm) and ('cluster_members' in self._gc_cm):
self.link_galaxy_cluster_with_cluster_members()

# =============================< CATALOG >=============================
def register_catalog(self, data):
"""
Expand Down Expand Up @@ -210,7 +222,6 @@ def register_catalog(self, data):
if data.get('class') is not 'coadd_objects':
count = self.db.get_count(data.get('table'), schema=data.get('schema', None))


# Recuperar a classe do produto
cls = self.get_product_class(data.get('class'))

Expand All @@ -232,7 +243,7 @@ def register_catalog(self, data):

product, created = Catalog.objects.update_or_create(
prd_owner=self.owner,
prd_name=data.get('name'),
prd_name=data.get('name').replace(' ', '_').lower(),
tbl_database=data.get('database', None),
tbl_schema=data.get('schema', None),
tbl_name=data.get('table'),
Expand Down Expand Up @@ -266,6 +277,10 @@ def register_catalog(self, data):
# Registar as colunas do catalogo
self.register_catalog_content(product, data, created)

# se um processo tiver mais de um produto e eles forem galaxy_clusters e cluster_members
if (product.prd_class.pcl_name == 'galaxy_clusters') or (product.prd_class.pcl_name == 'cluster_members'):
self._gc_cm[product.prd_class.pcl_name] = product

return True
else:
raise Exception(
Expand Down Expand Up @@ -316,6 +331,7 @@ def product_content_association(self, product, data, created):
for p in data.get("association"):
if ('property' in p and p.get('property') is not None) and ('ucd' in p and p.get('ucd') is not None):
meta.append(p)

else:
# Se o produto for da classe coadd_objects fazer a associacao de colunas
# Tem um diferenca que o Y1A1 a coluna coadd_object tem outro nome
Expand Down Expand Up @@ -413,6 +429,37 @@ def product_tag(self, product, tags, add_release):
except Tag.DoesNotExist:
raise Exception("this Tag '%s' is not valid." % tag_name)

def link_galaxy_cluster_with_cluster_members(self):
"""
Este metodo so e executado caso um processo possua 2 produtos
1 da classe galaxy_clusters e outro da classe cluster_members
esses produtos devem ser linkados atraves do model ProductRelated
e necessario que o produto de members tenha uma propriedade com ucd meta.id.cross.
:return:
"""

gc = self._gc_cm.get('galaxy_clusters')
cm = self._gc_cm.get('cluster_members')

# descobrir a propriedade que tem a associacao de cross_identification no produto de cluster members
try:
cross_identification = ProductContent.objects.get(pcn_product_id=cm.pk, pcn_ucd='meta.id.cross')

prd_related = ProductRelated.objects.update_or_create(
prl_product=gc,
defaults={
"prl_related": cm,
"prl_cross_identification": cross_identification
}
)


except ProductContent.DoesNotExist:
raise Exception(
"this cluster members product %s does not have a property with ucd meta.id.cross to be associated with "
"the galaxy cluster product." % cm.prd_display_name)


# =============================< MAP >=============================
def register_map(self, data):
if not self.db:
Expand Down Expand Up @@ -444,7 +491,7 @@ def register_map(self, data):

product, created = Map.objects.update_or_create(
prd_owner=self.owner,
prd_name=data.get('name'),
prd_name=data.get('name').replace(' ', '_').lower(),
tbl_schema=data.get('schema', None),
tbl_name=data.get('table'),
defaults={
Expand Down Expand Up @@ -545,7 +592,7 @@ def register_mask(self, data):

product, created = Mask.objects.update_or_create(
prd_owner=self.owner,
prd_name=data.get('name'),
prd_name=data.get('name').replace(' ', '_').lower(),
tbl_schema=data.get('schema', None),
tbl_name=data.get('table'),
defaults={
Expand Down
2 changes: 1 addition & 1 deletion frontend/build/production/Sky/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/build/production/Sky/app.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"packages":{"aladin":{"css":true,"included":true,"required":true,"requires":["ext","core","classic","ux","common"],"version":"1.0.0"},"classic":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core"],"version":"6.0.1.250"},"cmd":{"current":"6.1.2.15","version":"6.5.1.240"},"common":{"css":true,"included":true,"required":true,"requires":["ext","core","classic","ux"],"version":"1.0.0"},"core":{"css":true,"included":true,"required":true,"requires":["ext","classic"],"version":"6.0.1.250"},"ext":{"css":true,"included":true,"license":"gpl","namespace":"Ext","required":true,"requires":[],"version":"6.0.1.250"},"font-awesome":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base","theme-neutral","theme-neptune"],"theme":"theme-neptune","version":"6.0.1.250"},"theme-base":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic"],"version":"6.0.1.250"},"theme-crisp":{"css":true,"extend":"theme-neptune","included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base","theme-neutral","theme-neptune"],"version":"6.0.1.250"},"theme-neptune":{"css":true,"extend":"theme-neutral","included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base","theme-neutral"],"version":"6.0.1.250"},"theme-neutral":{"css":true,"extend":"theme-base","included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base"],"version":"6.0.1.250"},"ux":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic"],"version":"6.0.1.250"},"visiomatic":{"css":true,"included":true,"namespace":"visiomatic","required":true,"requires":["ext","core","classic"],"version":"1.0.0"}},"js":[{"path":"packages/local/visiomatic/src/visiomatic/dist/jquery-min.js"},{"path":"packages/local/aladin/src/aladin/aladin-min.js"},{"path":"packages/local/visiomatic/src/Leaflet/dist/leaflet.js"},{"path":"packages/local/visiomatic/src/visiomatic/dist/jqplot-min.js"},{"path":"packages/local/visiomatic/src/visiomatic/dist/spectrum-min.js"},{"path":"packages/local/visiomatic/src/visiomatic/dist/visiomatic-src.js"},{"path":"app.js"}],"css":[{"path":"packages/local/aladin/src/aladin/aladin-min.css"},{"path":"packages/local/visiomatic/src/Leaflet/dist/leaflet.css"},{"path":"packages/local/visiomatic/src/visiomatic/dist/visiomatic.css"},{"path":"packages/local/visiomatic/src/visiomatic/dist/spectrum.css"},{"path":"packages/local/visiomatic/src/visiomatic/dist/jqplot.css"},{"remote":false,"exclude":["fashion"],"path":"resources/Sky-all_1.css"},{"remote":false,"exclude":["fashion"],"path":"resources/Sky-all_2.css"}],"cache":{"enable":true,"deltas":true},"fashion":{"inliner":{"enable":false}},"name":"Sky","version":"1.0.0.0","framework":"ext","toolkit":"classic","theme":"theme-crisp","loader":{"cache":"20171114171645","cacheParam":"_dc"},"id":"495a5aab-e912-414c-bd2d-7b69ef5766b9","hash":"d6451e35908be159c7ba21b2b0a5b1120c05f160","profile":"","resources":{"path":"resources"}}
{"packages":{"aladin":{"css":true,"included":true,"required":true,"requires":["ext","core","classic","ux","common"],"version":"1.0.0"},"classic":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core"],"version":"6.0.1.250"},"cmd":{"current":"6.1.2.15","version":"6.5.1.240"},"common":{"css":true,"included":true,"required":true,"requires":["ext","core","classic","ux"],"version":"1.0.0"},"core":{"css":true,"included":true,"required":true,"requires":["ext","classic"],"version":"6.0.1.250"},"ext":{"css":true,"included":true,"license":"gpl","namespace":"Ext","required":true,"requires":[],"version":"6.0.1.250"},"font-awesome":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base","theme-neutral","theme-neptune"],"theme":"theme-neptune","version":"6.0.1.250"},"theme-base":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic"],"version":"6.0.1.250"},"theme-crisp":{"css":true,"extend":"theme-neptune","included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base","theme-neutral","theme-neptune"],"version":"6.0.1.250"},"theme-neptune":{"css":true,"extend":"theme-neutral","included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base","theme-neutral"],"version":"6.0.1.250"},"theme-neutral":{"css":true,"extend":"theme-base","included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base"],"version":"6.0.1.250"},"ux":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic"],"version":"6.0.1.250"},"visiomatic":{"css":true,"included":true,"namespace":"visiomatic","required":true,"requires":["ext","core","classic"],"version":"1.0.0"}},"js":[{"path":"packages/local/visiomatic/src/visiomatic/dist/jquery-min.js"},{"path":"packages/local/aladin/src/aladin/aladin-min.js"},{"path":"packages/local/visiomatic/src/Leaflet/dist/leaflet.js"},{"path":"packages/local/visiomatic/src/visiomatic/dist/jqplot-min.js"},{"path":"packages/local/visiomatic/src/visiomatic/dist/spectrum-min.js"},{"path":"packages/local/visiomatic/src/visiomatic/dist/visiomatic-src.js"},{"path":"app.js"}],"css":[{"path":"packages/local/aladin/src/aladin/aladin-min.css"},{"path":"packages/local/visiomatic/src/Leaflet/dist/leaflet.css"},{"path":"packages/local/visiomatic/src/visiomatic/dist/visiomatic.css"},{"path":"packages/local/visiomatic/src/visiomatic/dist/spectrum.css"},{"path":"packages/local/visiomatic/src/visiomatic/dist/jqplot.css"},{"remote":false,"exclude":["fashion"],"path":"resources/Sky-all_1.css"},{"remote":false,"exclude":["fashion"],"path":"resources/Sky-all_2.css"}],"cache":{"enable":true,"deltas":true},"fashion":{"inliner":{"enable":false}},"name":"Sky","version":"1.0.0.0","framework":"ext","toolkit":"classic","theme":"theme-crisp","loader":{"cache":"20171123111239","cacheParam":"_dc"},"id":"495a5aab-e912-414c-bd2d-7b69ef5766b9","hash":"52aa10a641944b2f6ac300b2b947e7d50efc524b","profile":"","resources":{"path":"resources"}}
2 changes: 1 addition & 1 deletion frontend/build/production/Target/app.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"packages":{"classic":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core"],"version":"6.0.1.250"},"cmd":{"current":"6.5.1.240","version":"6.5.1.240"},"common":{"css":true,"included":true,"required":true,"requires":["ext","core","classic","ux"],"version":"1.0.0"},"core":{"css":true,"included":true,"required":true,"requires":["ext","classic"],"version":"6.0.1.250"},"ext":{"css":true,"included":true,"license":"gpl","namespace":"Ext","required":true,"requires":[],"version":"6.0.1.250"},"font-awesome":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base","theme-neutral","theme-neptune"],"theme":"theme-neptune","version":"6.0.1.250"},"theme-base":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic"],"version":"6.0.1.250"},"theme-crisp":{"css":true,"extend":"theme-neptune","included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base","theme-neutral","theme-neptune"],"version":"6.0.1.250"},"theme-neptune":{"css":true,"extend":"theme-neutral","included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base","theme-neutral"],"version":"6.0.1.250"},"theme-neutral":{"css":true,"extend":"theme-base","included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base"],"version":"6.0.1.250"},"ux":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic"],"version":"6.0.1.250"},"visiomatic":{"css":true,"included":true,"namespace":"visiomatic","required":true,"requires":["ext","core","classic"],"version":"1.0.0"}},"js":[{"path":"packages/local/visiomatic/src/Leaflet/dist/leaflet.js"},{"path":"packages/local/visiomatic/src/visiomatic/dist/jquery-min.js"},{"path":"packages/local/visiomatic/src/visiomatic/dist/jqplot-min.js"},{"path":"packages/local/visiomatic/src/visiomatic/dist/spectrum-min.js"},{"path":"packages/local/visiomatic/src/visiomatic/dist/visiomatic-src.js"},{"path":"app.js"}],"css":[{"path":"packages/local/visiomatic/src/Leaflet/dist/leaflet.css"},{"path":"packages/local/visiomatic/src/visiomatic/dist/visiomatic.css"},{"path":"packages/local/visiomatic/src/visiomatic/dist/spectrum.css"},{"path":"packages/local/visiomatic/src/visiomatic/dist/jqplot.css"},{"exclude":["fashion"],"path":"resources/Target-all.css"}],"cache":{"enable":true,"deltas":true},"fashion":{"inliner":{"enable":false}},"name":"Target","version":"1.0.0.0","framework":"ext","toolkit":"classic","theme":"theme-crisp","loader":{"cache":"20171117233853","cacheParam":"_dc"},"id":"85a0e2c2-ad9b-4f4a-84ed-649bd3f711fd","hash":"f533fe7447f2dd684a6d79bef50274c88ec67c19","profile":"","resources":{"path":"resources"}}
{"packages":{"classic":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core"],"version":"6.0.1.250"},"cmd":{"current":"6.5.1.240","version":"6.5.1.240"},"common":{"css":true,"included":true,"required":true,"requires":["ext","core","classic","ux"],"version":"1.0.0"},"core":{"css":true,"included":true,"required":true,"requires":["ext","classic"],"version":"6.0.1.250"},"ext":{"css":true,"included":true,"license":"gpl","namespace":"Ext","required":true,"requires":[],"version":"6.0.1.250"},"font-awesome":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base","theme-neutral","theme-neptune"],"theme":"theme-neptune","version":"6.0.1.250"},"theme-base":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic"],"version":"6.0.1.250"},"theme-crisp":{"css":true,"extend":"theme-neptune","included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base","theme-neutral","theme-neptune"],"version":"6.0.1.250"},"theme-neptune":{"css":true,"extend":"theme-neutral","included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base","theme-neutral"],"version":"6.0.1.250"},"theme-neutral":{"css":true,"extend":"theme-base","included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic","theme-base"],"version":"6.0.1.250"},"ux":{"css":true,"included":true,"namespace":"Ext","required":true,"requires":["ext","core","classic"],"version":"6.0.1.250"},"visiomatic":{"css":true,"included":true,"namespace":"visiomatic","required":true,"requires":["ext","core","classic"],"version":"1.0.0"}},"js":[{"path":"packages/local/visiomatic/src/Leaflet/dist/leaflet.js"},{"path":"packages/local/visiomatic/src/visiomatic/dist/jquery-min.js"},{"path":"packages/local/visiomatic/src/visiomatic/dist/jqplot-min.js"},{"path":"packages/local/visiomatic/src/visiomatic/dist/spectrum-min.js"},{"path":"packages/local/visiomatic/src/visiomatic/dist/visiomatic-src.js"},{"path":"app.js"}],"css":[{"path":"packages/local/visiomatic/src/Leaflet/dist/leaflet.css"},{"path":"packages/local/visiomatic/src/visiomatic/dist/visiomatic.css"},{"path":"packages/local/visiomatic/src/visiomatic/dist/spectrum.css"},{"path":"packages/local/visiomatic/src/visiomatic/dist/jqplot.css"},{"exclude":["fashion"],"path":"resources/Target-all.css"}],"cache":{"enable":true,"deltas":true},"fashion":{"inliner":{"enable":false}},"name":"Target","version":"1.0.0.0","framework":"ext","toolkit":"classic","theme":"theme-crisp","loader":{"cache":"20171121105442","cacheParam":"_dc"},"id":"85a0e2c2-ad9b-4f4a-84ed-649bd3f711fd","hash":"86a4c351cc6439f73794f77ef3563677b87629a6","profile":"","resources":{"path":"resources"}}
Loading

0 comments on commit a7b07b6

Please sign in to comment.