<commit_before>package com.celements.crm.place;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xwiki.component.annotation.Component;
import org.xwiki.model.reference.DocumentReference;

import com.celements.common.classes.AbstractClassCollection;
import com.xpn.xwiki.XWikiException;
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.objects.classes.BaseClass;

@Component("celements.crm.places")
public class PlaceClasses extends AbstractClassCollection {
  
  private static Log LOGGER = LogFactory.getFactory().getInstance(PlaceClasses.class);
  
  public void initClasses() throws XWikiException {
    getAddressClass();
    getCityClass();
  }

  public DocumentReference getAddressClassRef(String wikiName) {
    return new DocumentReference(wikiName, "CelementsPlaces", "AddressClass");
  }

  BaseClass getAddressClass() throws XWikiException {
    XWikiDocument doc;
    boolean needsUpdate = false;
    DocumentReference classRef = getAddressClassRef(getContext().getDatabase());
    try {
      doc = getContext().getWiki().getDocument(classRef, getContext());
    } catch (XWikiException exp) {
      LOGGER.error("Failed to get address class document.", exp);
      doc = new XWikiDocument(classRef);
      needsUpdate = true;
    }

    BaseClass bclass = doc.getXClass();
    bclass.setXClassReference(classRef);
    needsUpdate |= bclass.addTextField("street", "Street", 30);
    needsUpdate |= bclass.addTextField("houseNumber", "House Number", 30);
    needsUpdate |= bclass.addTextField("zip", "ZIP", 30);
    needsUpdate |= bclass.addTextField("city", "City", 30);
    needsUpdate |= bclass.addTextField("country", "Country", 30);
    needsUpdate |= bclass.addDateField("validFrom", "valid from date", "dd.MM.yyy", 0);
    needsUpdate |= bclass.addDateField("validUntil", "valid until date", "dd.MM.yyy", 0);
    
    if(!"internal".equals(bclass.getCustomMapping())){
      needsUpdate = true;
      bclass.setCustomMapping("internal");
    }
    
    setContentAndSaveClassDocument(doc, needsUpdate);
    return bclass;
  }

  public DocumentReference getCityClassRef(String wikiName) {
    return new DocumentReference(wikiName, "CelementsPlaces", "CityClass");
  }

  BaseClass getCityClass() throws XWikiException {
    XWikiDocument doc;
    boolean needsUpdate = false;
    DocumentReference classRef = getCityClassRef(getContext().getDatabase());
    try {
      doc = getContext().getWiki().getDocument(classRef, getContext());
    } catch (XWikiException exp) {
      LOGGER.error("Failed to get city class document.", exp);
      doc = new XWikiDocument(classRef);
      needsUpdate = true;
    }

    BaseClass bclass = doc.getXClass();
    bclass.setXClassReference(classRef);
    needsUpdate |= bclass.addTextField("zip", "ZIP", 8);
    needsUpdate |= bclass.addTextField("shortName", "City Short Name", 30);
    needsUpdate |= bclass.addTextField("name", "City Name", 30);
    needsUpdate |= bclass.addTextField("county", "County", 30);
    needsUpdate |= bclass.addTextField("primaryLanguage", "Primary Language", 30);
    needsUpdate |= bclass.addTextField("countryISONum", "Country ISO Number", 30);
    needsUpdate |= bclass.addDateField("validFrom", "valid from date", "dd.MM.yyy", 0);
    needsUpdate |= bclass.addDateField("validUntil", "valid until date", "dd.MM.yyy", 0);
    
    if(!"internal".equals(bclass.getCustomMapping())){
      needsUpdate = true;
      bclass.setCustomMapping("internal");
    }
    
    setContentAndSaveClassDocument(doc, needsUpdate);
    return bclass;
  }

  public DocumentReference getCityNameClassRef(String wikiName) {
    return new DocumentReference(wikiName, "CelementsPlaces", "CityNameClass");
  }
<commit_msg>fix create countryISONum field in CityClass <commit_after>package com.celements.crm.place;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xwiki.component.annotation.Component;
import org.xwiki.model.reference.DocumentReference;

import com.celements.common.classes.AbstractClassCollection;
import com.xpn.xwiki.XWikiException;
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.objects.classes.BaseClass;

@Component("celements.crm.places")
public class PlaceClasses extends AbstractClassCollection {
  
  private static Log LOGGER = LogFactory.getFactory().getInstance(PlaceClasses.class);
  
  public void initClasses() throws XWikiException {
    getAddressClass();
    getCityClass();
  }

  public DocumentReference getAddressClassRef(String wikiName) {
    return new DocumentReference(wikiName, "CelementsPlaces", "AddressClass");
  }

  BaseClass getAddressClass() throws XWikiException {
    XWikiDocument doc;
    boolean needsUpdate = false;
    DocumentReference classRef = getAddressClassRef(getContext().getDatabase());
    try {
      doc = getContext().getWiki().getDocument(classRef, getContext());
    } catch (XWikiException exp) {
      LOGGER.error("Failed to get address class document.", exp);
      doc = new XWikiDocument(classRef);
      needsUpdate = true;
    }

    BaseClass bclass = doc.getXClass();
    bclass.setXClassReference(classRef);
    needsUpdate |= bclass.addTextField("street", "Street", 30);
    needsUpdate |= bclass.addTextField("houseNumber", "House Number", 30);
    needsUpdate |= bclass.addTextField("zip", "ZIP", 30);
    needsUpdate |= bclass.addTextField("city", "City", 30);
    needsUpdate |= bclass.addTextField("country", "Country", 30);
    needsUpdate |= bclass.addDateField("validFrom", "valid from date", "dd.MM.yyy", 0);
    needsUpdate |= bclass.addDateField("validUntil", "valid until date", "dd.MM.yyy", 0);
    
    if(!"internal".equals(bclass.getCustomMapping())){
      needsUpdate = true;
      bclass.setCustomMapping("internal");
    }
    
    setContentAndSaveClassDocument(doc, needsUpdate);
    return bclass;
  }

  public DocumentReference getCityClassRef(String wikiName) {
    return new DocumentReference(wikiName, "CelementsPlaces", "CityClass");
  }

  BaseClass getCityClass() throws XWikiException {
    XWikiDocument doc;
    boolean needsUpdate = false;
    DocumentReference classRef = getCityClassRef(getContext().getDatabase());
    try {
      doc = getContext().getWiki().getDocument(classRef, getContext());
    } catch (XWikiException exp) {
      LOGGER.error("Failed to get city class document.", exp);
      doc = new XWikiDocument(classRef);
      needsUpdate = true;
    }

    BaseClass bclass = doc.getXClass();
    bclass.setXClassReference(classRef);
    needsUpdate |= bclass.addTextField("zip", "ZIP", 8);
    needsUpdate |= bclass.addTextField("shortName", "City Short Name", 30);
    needsUpdate |= bclass.addTextField("name", "City Name", 30);
    needsUpdate |= bclass.addTextField("county", "County", 30);
    needsUpdate |= bclass.addTextField("primaryLanguage", "Primary Language", 30);
    needsUpdate |= bclass.addNumberField("countryISONum", "Country ISO Number", 3,
        "integer");
    needsUpdate |= bclass.addDateField("validFrom", "valid from date", "dd.MM.yyy", 0);
    needsUpdate |= bclass.addDateField("validUntil", "valid until date", "dd.MM.yyy", 0);
    
    if(!"internal".equals(bclass.getCustomMapping())){
      needsUpdate = true;
      bclass.setCustomMapping("internal");
    }
    
    setContentAndSaveClassDocument(doc, needsUpdate);
    return bclass;
  }

  public DocumentReference getCityNameClassRef(String wikiName) {
    return new DocumentReference(wikiName, "CelementsPlaces", "CityNameClass");
  }

{'fraction_non_alphanumeric': 0.12756113681427628, 'fraction_numerical': 0.006477197620621282, 'mean_word_length': 4.5469208211143695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '378043', 'n_tokens_mistral': 2283, 'n_tokens_neox': 2202, 'n_words': 463}