Module: Msoa_dataFilter
- Defined in:
- lib/ontomde-java/java/component.rb
Instance Method Summary collapse
-
#dto_createAssociatedField(dtoClass, sourceField) ⇒ Object
create a field in dto class associated to sourceField.
- #dto_findFilterByName(filterName) ⇒ Object
- #dto_getDataFilter(sourceField) ⇒ Object
- #dto_getFilteredClass(umlClass) ⇒ Object
- #dto_getFilterRule(field) ⇒ Object
- #dto_populateDTO(dto, umlClass) ⇒ Object
- #soa_getFullDataFilter ⇒ Object
-
#soa_getIdDataFilter ⇒ Object
return predefinedFilterRule none.
-
#soa_getIgnoreDataFilter ⇒ Object
return predefinedFilterRule none.
- #soa_getPredefinedDataFilter(name, suggestion = nil) ⇒ Object
Instance Method Details
#dto_createAssociatedField(dtoClass, sourceField) ⇒ Object
create a field in dto class associated to sourceField.
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File 'lib/ontomde-java/java/component.rb', line 478 def dto_createAssociatedField(dtoClass,sourceField) #log.debug { %{add form field #{self} to #{form}} } #return unless sourceField.umlx_businessMethod? puts "adding field for #{sourceField} in dto #{dtoClass} m=#{self}" filter=dto_getDataFilter(sourceField) # if filter.nil? # puts "missing useDataFilter for filterRule #{filterRule}" # return # end if filter.soa_dataFilterName.to_s=="IGNORE" puts "IGNORE data filter" return end puts "filter=#{filter.soa_dataFilterName}" targetType=filter.dto_getFilteredClass(sourceField.uml_type_one) if targetType.nil? puts "nil filtered type returned for #{sourceField}" return end a2=dtoClass.umlx_createAndAddProperty(sourceField.rdf_uri+"_dtoField") a2.uml_name=sourceField.uml_name a2.uml_upperValue=sourceField.uml_upperValue a2.uml_lowerValue=sourceField.uml_lowerValue a2.java_use_Arrays=RDF_TRUE # a2.struts_sourceProperty=self a2.uml_type=targetType a2.uml_type=a2.umlx_owner_one.umlx_dataType_string if a2.uml_type_one0.nil? return a2 end |
#dto_findFilterByName(filterName) ⇒ Object
359 360 361 362 363 364 365 366 367 |
# File 'lib/ontomde-java/java/component.rb', line 359 def dto_findFilterByName(filterName) data_model=rdf_Repository #self[:dataModel] data_model.each_value { |rule| next unless rule.kind_of?(Msoa_dataFilter) next unless rule.soa_dataFilterName.to_s==filterName return rule } raise Exception.new("soa filter not found with name='#{filterName}'") end |
#dto_getDataFilter(sourceField) ⇒ Object
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/ontomde-java/java/component.rb', line 369 def dto_getDataFilter(sourceField) if self.soa_dataFilterName.to_s=="ID" return (sourceField.uml_name.to_s=="id") ? dto_findFilterByName("INCLUDE") : soa_getIgnoreDataFilter() end if self.soa_dataFilterName.to_s=="FULL" return dto_findFilterByName("ID") end filterRule=dto_getFilterRule(sourceField) if filterRule.nil? #puts "field ignored :#{sourceField} (#{sourceField.umlx_owner_one})" return soa_getIgnoreDataFilter end filter=filterRule.soa_useDataFilter_one0 return soa_getIgnoreDataFilter if filter.nil? return filter end |
#dto_getFilteredClass(umlClass) ⇒ Object
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
# File 'lib/ontomde-java/java/component.rb', line 412 def dto_getFilteredClass(umlClass) if umlClass.kind_of?(Muml_PrimitiveType) || umlClass.kind_of?(Muml_DataType) || umlClass.java_isATestFile? || umlClass.umlx_hasStereotype?('DTO') # umlClass is a already a DTO. No further action required. return umlClass end if self.soa_dataFilterName.to_s=="INCLUDE" puts "!!! #{umlClass} INCLUDED" return umlClass end return umlClass if umlClass.java_qualifiedName.to_s.index("java.")==0 # umlClass is not a DTO. We now need to compute a DTO class for it. dto=nil if umlClass.kind_of?(Muml_Class) dto=umlClass.umlx_getOrCreateClass("filter."+self.soa_dataFilterName.to_s+"."+umlClass.java_qualifiedName.to_s+"_"+self.soa_dataFilterName.to_s) else dto=umlClass.umlx_getOrCreateInterface("filter."+self.soa_dataFilterName.to_s+"."+umlClass.java_qualifiedName.to_s+"_"+self.soa_dataFilterName.to_s) end dto_populateDTO(dto,umlClass) unless dto.dto_isPopulated? return dto end |
#dto_getFilterRule(field) ⇒ Object
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/ontomde-java/java/component.rb', line 387 def dto_getFilterRule(field) raise Exception.new("field nil") if field.nil? r=nil soa_sourceDataFilter_inv.each { |f| #puts "f --> #{f.class} #{f.soa_filteredProperty.class}:[#{f.soa_filteredProperty}] #{field.rdf_uri} " found=false f.soa_filteredProperty.each {|z| # z is a Ckb_UML_SLOT #puts "z----> #{z.to_s} #{field.rdf_uri}" next unless z.to_s==field.rdf_uri.to_s found=true break } next unless found #next unless f.soa_filteredProperty.include?(field) #puts "f --> OK " unless r.nil? puts "TODO: error multiple source data filter for field #{f}" end r=f } return r end |
#dto_populateDTO(dto, umlClass) ⇒ Object
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
# File 'lib/ontomde-java/java/component.rb', line 438 def dto_populateDTO(dto,umlClass) dto.dto_isPopulated=RDF_TRUE dto.uml_appliedStereotype_add(dto.umlx_getOrCreateStereotype("DTO")) dto.umlx_external=RDF_FALSE dto.db_isTransient=RDF_TRUE dto.umlx_businessMethod=RDF_FALSE if(umlClass.kind_of?(Muml_Class)) umlClass.uml_implementation.each {|g| clazz=dto_getFilteredClass(g.uml_supplier_one) if clazz.nil? puts "No filter #{self} for #{g.uml_supplier_one}. Class ignore in inheritance" next end dto.umlx_createAndAddImplementation(clazz) } end #puts "dto=#{dto}" umlClass.uml_generalization.each {|g| #adds generalization from element in same mode as current. clazz=dto_getFilteredClass(g.uml_general_one) #puts "generalization for #{umlClass} : #{g.uml_general_one} --> #{clazz}" if clazz.nil? puts "No filter #{self} for #{g.uml_general_one}. Class ignore in inheritance" next end dto.umlx_createAndAddGeneralization(clazz) } umlClass.uml_ownedAttribute.each { |sourceField| # puts "sourcField-->#{umlClass} : #{sourceField}" # f=dto_getFilterRule(p) next if sourceField.uml_isStatic? #next if sourceField.uml_isFinal? dto_createAssociatedField(dto,sourceField) } return dto end |
#soa_getFullDataFilter ⇒ Object
334 335 336 |
# File 'lib/ontomde-java/java/component.rb', line 334 def soa_getFullDataFilter() return soa_getPredefinedDataFilter('FULL') end |
#soa_getIdDataFilter ⇒ Object
return predefinedFilterRule none
331 332 333 |
# File 'lib/ontomde-java/java/component.rb', line 331 def soa_getIdDataFilter() return soa_getPredefinedDataFilter('ID') end |
#soa_getIgnoreDataFilter ⇒ Object
return predefinedFilterRule none
325 326 327 328 329 |
# File 'lib/ontomde-java/java/component.rb', line 325 def soa_getIgnoreDataFilter() return soa_getPredefinedDataFilter('IGNORE', self.rdf_Repository.soa_IgnoreDataFilter) { |v| self.rdf_Repository.soa_IgnoreDataFilter=v } end |
#soa_getPredefinedDataFilter(name, suggestion = nil) ⇒ Object
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
# File 'lib/ontomde-java/java/component.rb', line 338 def soa_getPredefinedDataFilter(name,suggestion=nil) ret=suggestion if ret.nil? rdf_Repository.each {|k,v| next unless v.kind_of?(Msoa_predefinedDataFilter) next unless v.soa_dataFilterName.to_s==name ret=v break } if ret.nil? ret=Csoa_predefinedDataFilter.new(rdf_Repository,"uri://soa_filter_#{name}") ret.soa_dataFilterName=name end yield(ret) end #puts "!!! #{name} filter" return ret end |