congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CategoryOption
Code IndexAdd Tabnine to your IDE (free)

How to use
CategoryOption
in
org.hisp.dhis.category

Best Java code snippets using org.hisp.dhis.category.CategoryOption (Showing top 20 results out of 315)

origin: dhis2/dhis2-core

public static CategoryOption createCategoryOption( char uniqueIdentifier )
{
  CategoryOption categoryOption = new CategoryOption( "CategoryOption" + uniqueIdentifier );
  categoryOption.setAutoFields();
  return categoryOption;
}
origin: dhis2/dhis2-core

public CategoryOption getCategoryOption( CategoryOptionCombo categoryOptionCombo )
{
  for ( CategoryOption categoryOption : categoryOptions )
  {
    if ( categoryOption.getCategoryOptionCombos().contains( categoryOptionCombo ) )
    {
      return categoryOption;
    }
  }
  return null;
}
origin: dhis2/dhis2-core

public void removeAllCategoryOptions()
{
  for ( CategoryOption categoryOption : categoryOptions )
  {
    categoryOption.getCategories().remove( this );
  }
  categoryOptions.clear();
}
origin: dhis2/dhis2-core

public Date getEarliestEndDate()
{
  Date earliestEndDate = null;
  for ( CategoryOption co : getCategoryOptions() )
  {
    if ( co.getEndDate() != null )
    {
      earliestEndDate = (earliestEndDate == null || earliestEndDate.after( co.getEndDate() ) ?
        co.getStartDate() : earliestEndDate);
    }
  }
  return earliestEndDate;
}
origin: dhis2/dhis2-core

  identifier = catopt.getUid().trim();
  break;
case CODE:
  identifier = catopt.getCode().trim();
  break;
case NAME:
  identifier = catopt.getName().trim();
  break;
default:
throw new CategoryComboMapException( "No " + idScheme.toString() + " identifier for CategoryOption: " + catopt.getName() );
origin: dhis2/dhis2-core

@Override
public List<String> canRead( User user, CategoryOptionCombo optionCombo )
{
  List<String> errors = new ArrayList<>();
  if ( user == null || user.isSuper() )
  {
    return errors;
  }
  Set<CategoryOption> options = optionCombo.getCategoryOptions();
  options.forEach( attrOption -> {
    if ( !aclService.canDataRead( user, attrOption ) )
    {
      errors.add( "User has no data read access for CategoryOption: " + attrOption.getUid() );
    }
  } );
  return errors;
}
origin: dhis2/dhis2-core

private List<CategoryOption> categoryOptionsFromCsv( CsvReader reader )
  throws IOException
{
  List<CategoryOption> list = new ArrayList<>();
  while ( reader.readRecord() )
  {
    String[] values = reader.getValues();
    if ( values != null && values.length > 0 )
    {
      CategoryOption object = new CategoryOption();
      setIdentifiableObject( object, values );
      object.setShortName( getSafe( values, 3, object.getName(), 50 ) );
      list.add( object );
    }
  }
  return list;
}
origin: dhis2/dhis2-core

CategoryOption categoryOption = new CategoryOption( CategoryOption.DEFAULT_NAME );
categoryOption.setUid( "xYerKDKCefk" );
categoryOption.setCode( "default" );
categoryOption.setPublicAccess( AccessStringHelper.CATEGORY_OPTION_DEFAULT );
updateCategoryOption( categoryOption );
categoryOption.setCategoryOptionCombos( categoryOptionCombos );
updateCategoryOption( categoryOption );
origin: dhis2/dhis2-core

grid.addHeader( new GridHeader( categoryOption.getName(), false, false ) );
  Object value = subTotalMap.get( dataElement.getUid() + SEPARATOR + categoryOption.getUid() );
origin: dhis2/dhis2-core

private void addExplodedCategoryAttributes( CategoryOptionCombo coc )
  throws AdxException
{
  Map<String, String> categoryAttributes = new HashMap<>();
  if ( !coc.isDefault() )
  {
    for ( Category category : coc.getCategoryCombo().getCategories() )
    {
      String categoryCode = category.getCode();
      
      if ( categoryCode == null || !XMLChar.isValidName( categoryCode ) )
      {
        throw new AdxException(
          "Category code for " + category.getName() + " is missing or invalid: " + categoryCode );
      }
      String catOptCode = category.getCategoryOption( coc ).getCode();
      
      if ( catOptCode == null || catOptCode.isEmpty() )
      {
        throw new AdxException(
          "CategoryOption code for " + category.getCategoryOption( coc ).getName() + " is missing" );
      }
      categoryAttributes.put( categoryCode, catOptCode );
    }
  }
  categoryOptionMap.put( coc.getId(), categoryAttributes );
}
origin: dhis2/dhis2-core

@Override
public String allowDeleteCategoryOption( CategoryOption categoryOption )
{
  String sql = "select count(*) from categorydimension_items where categoryoptionid = " + categoryOption.getId();
  
  return jdbcTemplate.queryForObject( sql, Integer.class ) == 0 ? null : ERROR;
}

origin: dhis2/dhis2-core

public void addCategoryOption( CategoryOption categoryOption )
{
  members.add( categoryOption );
  categoryOption.getGroups().add( this );
}
origin: dhis2/dhis2-core

/**
 * @param categoryComboUniqueIdentifier   A unique character to identify the
 *                                        category combo.
 * @param categoryOptionUniqueIdentifiers Unique characters to identify the
 *                                        category options.
 * @return CategoryOptionCombo
 */
public static CategoryOptionCombo createCategoryOptionCombo( char categoryComboUniqueIdentifier,
  char... categoryOptionUniqueIdentifiers )
{
  CategoryOptionCombo categoryOptionCombo = new CategoryOptionCombo();
  categoryOptionCombo.setAutoFields();
  categoryOptionCombo.setCategoryCombo( new CategoryCombo( "CategoryCombo"
    + categoryComboUniqueIdentifier, DataDimensionType.DISAGGREGATION ) );
  for ( char identifier : categoryOptionUniqueIdentifiers )
  {
    categoryOptionCombo.getCategoryOptions()
      .add( new CategoryOption( "CategoryOption" + identifier ) );
  }
  return categoryOptionCombo;
}
origin: dhis2/dhis2-core

/**
 * Returns a set of category option group sets which are linked to this data
 * set through its category combination.
 */
public Set<CategoryOptionGroupSet> getCategoryOptionGroupSets()
{
  Set<CategoryOptionGroupSet> groupSets = new HashSet<>();
  if ( categoryCombo != null )
  {
    for ( Category category : categoryCombo.getCategories() )
    {
      for ( CategoryOption categoryOption : category.getCategoryOptions() )
      {
        groupSets.addAll( categoryOption.getGroupSets() );
      }
    }
  }
  return groupSets;
}
origin: dhis2/dhis2-core

@Override
public List<String> canWrite( User user, CategoryOptionCombo optionCombo )
{
  List<String> errors = new ArrayList<>();
  if ( user == null || user.isSuper() )
  {
    return errors;
  }
  Set<CategoryOption> options = optionCombo.getCategoryOptions();
  options.forEach( attrOption -> {
    if ( !aclService.canDataWrite( user, attrOption ) )
    {
      errors.add( "User has no data write access for CategoryOption: " + attrOption.getUid() );
    }
  } );
  return errors;
}
origin: dhis2/dhis2-core

/**
 * Gets a range of valid dates for this (attribute) cateogry option combo.
 * <p>
 * The earliest valid date is the latest start date (if any) from all the
 * category options associated with this option combo.
 * <p>
 * The latest valid date is the earliest end date (if any) from all the
 * category options associated with this option combo.
 *
 * @return valid date range for this (attribute) category option combo.
 */
public DateRange getDateRange()
{
  Date latestStartDate = null;
  Date earliestEndDate = null;
  for ( CategoryOption option : getCategoryOptions() )
  {
    if ( option.getStartDate() != null && (latestStartDate == null || option.getStartDate().compareTo( latestStartDate ) > 0) )
    {
      latestStartDate = option.getStartDate();
    }
    if ( option.getEndDate() != null && (earliestEndDate == null || option.getStartDate().compareTo( earliestEndDate ) < 0) )
    {
      earliestEndDate = option.getEndDate();
    }
  }
  return new DateRange( latestStartDate, earliestEndDate );
}
origin: dhis2/dhis2-core

"where dv.categoryoptioncomboid in ( " +
  "select cc.categoryoptioncomboid from categoryoptioncombos_categoryoptions cc " +
  "where cc.categoryoptionid = " + categoryOption.getId() + " ) " +
"or dv.attributeoptioncomboid in ( " +
  "select cc.categoryoptioncomboid from categoryoptioncombos_categoryoptions cc " +
  "where cc.categoryoptionid = " + categoryOption.getId() + " );";
"where cdr.attributeoptioncomboid in ( " +
  "select cc.categoryoptioncomboid from categoryoptioncombos_categoryoptions cc " +
  "where cc.categoryoptionid = " + categoryOption.getId() + " );";
origin: dhis2/dhis2-core

  public void removeCategoryOption( CategoryOption categoryOption )
  {
    members.remove( categoryOption );
    categoryOption.getGroups().remove( this );
  }
}
origin: dhis2/dhis2-core

if ( option.getGroupSets() != null )
  cogSets.addAll( option.getGroupSets() );
origin: dhis2/dhis2-core

@Override
public List<String> canRead( User user, CategoryOptionCombo categoryOptionCombo )
{
  List<String> errors = new ArrayList<>();
  if ( user == null || user.isSuper() || categoryOptionCombo == null )
  {
    return errors;
  }
  for ( CategoryOption categoryOption : categoryOptionCombo.getCategoryOptions() )
  {
    if ( !aclService.canDataRead( user, categoryOption ) )
    {
      errors.add( "User has no read access to category option: " + categoryOption.getUid() );
    }
  }
  return errors;
}
org.hisp.dhis.categoryCategoryOption

Most used methods

  • getUid
  • <init>
  • getCategoryOptionCombos
  • getName
  • getCategories
  • getCode
  • getEndDate
  • getGroupSets
    Returns a set of category option group sets which are associated with the category option groups of
  • getGroups
  • getId
  • getStartDate
  • addCategoryOptionCombo
  • getStartDate,
  • addCategoryOptionCombo,
  • getDisplayName,
  • getOrganisationUnits,
  • includes,
  • setAutoFields,
  • setCategoryOptionCombos,
  • setCode,
  • setPublicAccess,
  • setShortName

Popular in Java

  • Updating database using SQL prepared statement
  • setScale (BigDecimal)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • requestLocationUpdates (LocationManager)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Collectors (java.util.stream)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now